Message388211
It is possible to run into an IndexError in the subprocess module's _communicate function.
```
return run(
File "subprocess.py", line 491, in run
File "subprocess.py", line 1024, in communicate
File "subprocess.py", line 1418, in _communicate
IndexError: list index out of range
```
The lines in question are:
```
if stdout is not None:
stdout = stdout[0]
if stderr is not None:
stderr = stderr[0]
```
I believe this is due to the fact there is no safety checking to make sure that self._stdout_buff and self._stderr_buff have any content in them after being set to empty lists.
The fix I suggest is to change the checks from `if stdout is not None` to simply `if stdout` to make sure it is a populated list.
Example fixed code:
```
if stdout:
stdout = stdout[0]
if stderr:
stderr = stderr[0]
```
If a more stringent check is required, we could expand that out to check type and length, such as `isinstance(stdout, list) and len(stdout) > 0:` but that is more then necessary currently. |
|
Date |
User |
Action |
Args |
2021-03-06 18:52:42 | cdgriffith | set | recipients:
+ cdgriffith |
2021-03-06 18:52:42 | cdgriffith | set | messageid: <1615056762.46.0.090803448155.issue43423@roundup.psfhosted.org> |
2021-03-06 18:52:42 | cdgriffith | link | issue43423 messages |
2021-03-06 18:52:42 | cdgriffith | create | |
|