New submission from Chris Jerdonek:

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).

----------
components: Library (Lib)
messages: 167694
nosy: cjerdonek
priority: normal
severity: normal
stage: test needed
status: open
title: subprocess.communicate() breaks on no input with universal newlines true
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15592>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to