[New-bugs-announce] [issue30203] AttributeError in Popen.communicate()
Luke Campagnola
report at bugs.python.org
Sat Apr 29 04:21:08 EDT 2017
New submission from Luke Campagnola:
In my application, calling communicate() on a Popen instance is giving the following exception:
. . .
File "/usr/lib/python3.5/subprocess.py", line 1072, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/usr/lib/python3.5/subprocess.py", line 1693, in _communicate
stdout = self._fileobj2output[self.stdout]
AttributeError: 'Popen' object has no attribute '_fileobj2output'
I have not been able to reproduce this in a simple example, but I imagine this could happen if Popen._communicate() raises an exception in the first 20 lines or so--this would cause _communication_started to be set True, even though _fileobj2output has not been initialized.
I suggest setting self._fileobj2output = None in Popen.__init__() and changing the relevant code in _communicate() from
if not self._communication_started:
self._fileobj2output = {}
to:
if self._fileobj2output is None:
self._fileobj2output = {}
----------
messages: 292575
nosy: Luke Campagnola
priority: normal
severity: normal
status: open
title: AttributeError in Popen.communicate()
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30203>
_______________________________________
More information about the New-bugs-announce
mailing list