[New-bugs-announce] [issue2683] subprocess.Popen.communicate takes bytes, not str

Lenard Lindstrom report at bugs.python.org
Thu Apr 24 20:57:20 CEST 2008


New submission from Lenard Lindstrom <len-l at telus.net>:

subprocess.Popen.communicate is documented as taking a string as the 
input argument. Instead is accepts only a binary stream (bytes).

Python 3.0a4 (r30a4:62126, Apr  3 2008, 15:34:18) [MSC v.1500 32 bit 
(Intel)] on
 win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import Popen, PIPE
>>> p = Popen('command.com', stdin=PIPE)
>>> p.communicate("dir\n")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python30\lib\subprocess.py", line 588, in communicate
    self.stdin.write(input)
  File "C:\Python30\lib\io.py", line 844, in write
    raise TypeError("can't write str to binary stream")
TypeError: can't write str to binary stream

----------
components: Extension Modules
messages: 65740
nosy: kermode
severity: normal
status: open
title: subprocess.Popen.communicate takes bytes, not str
versions: Python 3.0

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2683>
__________________________________


More information about the New-bugs-announce mailing list