bpo-43423 Fix IndexError in subprocess _communicate function (GH-24777)
Check to make sure stdout and stderr are not empty before selecting an item from them in Windows subprocess._communicate. Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
87f649a409
commit
b4fc44bb2d
@ -1535,10 +1535,8 @@ class Popen(object):
|
|||||||
self.stderr.close()
|
self.stderr.close()
|
||||||
|
|
||||||
# All data exchanged. Translate lists into strings.
|
# All data exchanged. Translate lists into strings.
|
||||||
if stdout is not None:
|
stdout = stdout[0] if stdout else None
|
||||||
stdout = stdout[0]
|
stderr = stderr[0] if stderr else None
|
||||||
if stderr is not None:
|
|
||||||
stderr = stderr[0]
|
|
||||||
|
|
||||||
return (stdout, stderr)
|
return (stdout, stderr)
|
||||||
|
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
:func:`subprocess.communicate` no longer raises an IndexError when there is an
|
||||||
|
empty stdout or stderr IO buffer during a timeout on Windows.
|
Loading…
x
Reference in New Issue
Block a user