This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients chris.jerdonek
Date 2012-08-08.16:37:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1344443880.03.0.234384317121.issue15592@psf.upfronthosting.co.za>
In-reply-to
Content
Popen.communicate() raises an exception if passed no input when stdin=PIPE and universal_newlines=True.  With universal_newlines=False, no exception is raised.  For example, the following yields--

args = [sys.executable, '-c', 'pass']

popen = Popen(args, universal_newlines=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
print(popen.communicate())

popen = Popen(args, universal_newlines=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
print(popen.communicate())

(b'', b'[41449 refs]\n')
Traceback (most recent call last):
  ...
  File ".../Lib/subprocess.py", line 1581, in _communicate_with_poll
    self._input = self._input.encode(self.stdin.encoding)
AttributeError: 'NoneType' object has no attribute 'encode'

It seems like communicate() should not be trying to encode input if there is none.

I can provide a patch with tests if it is agreed this is an issue (along with a fix assuming it is reasonable).
History
Date User Action Args
2012-08-08 16:38:00chris.jerdoneksetrecipients: + chris.jerdonek
2012-08-08 16:38:00chris.jerdoneksetmessageid: <1344443880.03.0.234384317121.issue15592@psf.upfronthosting.co.za>
2012-08-08 16:37:59chris.jerdoneklinkissue15592 messages
2012-08-08 16:37:57chris.jerdonekcreate