New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subprocess timeout causes output to be returned as bytes in text mode #87597
Comments
|
Passing the argument However, if you give a timeout and that timeout expires, the raised Test output: |
|
communicate() is incomplete, so decoding the output may fail. For example, say the encoding is UTF-8, and the last multibyte character sequence (2-4 bytes) is incomplete. Maybe communicate() should always set In Windows, run() tries to complete communication, which is dysfunctional in cases. I created bpo-43346 to propose changing the design in Windows, in order to address 3 cases that can cause subprocess.run() to ignore the given timeout. The proposed change also sets an incomplete read of stdout and stderr as bytes objects, regardless of text mode, because I was simply matching what POSIX does in this case. |
|
Eryk Sun: Well, I think step 1 should be to update the documentation for Python 3.7 through 3.10 on If we went with the model of having |
|
Note: If you use |
|
There's another related bug here: when there's no output before the timeout is hit then you get the |
|
Unfortunately this counts as an API change as people will have written code since timeouts were introduced in 3.3 that blindly assumes TimeoutExpired.stdout/stderr are bytes. So while it might be a bug, it's also a breaking change and thus feature. Meaning it can't be backported. And likely needing a deprecation period. |
This documents the behavior that has always been the case since timeout support was introduced in Python 3.3.
This documents the behavior that has always been the case since timeout support was introduced in Python 3.3.
…nGH-97685) This documents the behavior that has always been the case since timeout support was introduced in Python 3.3. (cherry picked from commit b05dd79) Co-authored-by: Gregory P. Smith <greg@krypto.org>
…nGH-97685) This documents the behavior that has always been the case since timeout support was introduced in Python 3.3. (cherry picked from commit b05dd79) Co-authored-by: Gregory P. Smith <greg@krypto.org>
…nGH-97685) This documents the behavior that has always been the case since timeout support was introduced in Python 3.3. (cherry picked from commit b05dd79) Co-authored-by: Gregory P. Smith <greg@krypto.org>
…n#97685) This documents the behavior that has always been the case since timeout support was introduced in Python 3.3.
See python/cpython#97685 The union type should be acceptable given python/cpython#87597 (comment). In general I'd like us to be able to type this, since these being bytes can be surprising if you pass text=True, but we'll see what mypy_primer says


macdjord mannequin commentedMar 8, 2021
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: