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.

Title: subprocess.Popen.communicate does not encode unicode strings
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.5
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: beda, flox
Priority: normal Keywords:

Created on 2009-02-17 08:25 by beda, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg82304 - (view) Author: Beda Kosata (beda) Date: 2009-02-17 08:25
The method subprocess.Popen.communicate (more the underlying
_communicate) writes the input to the stdin stream without encoding,
regardless of it being a unicode string. The result is incorrect
behavior of the running program as it receives 4 bytes for each character.
As simple text program is here:

import subprocess
from base64 import b16encode

command = ["cat"]
p = subprocess.Popen(command, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
data = u"test text"
o, er = p.communicate(data)
print b16encode(o)

I believe that this issue is closely related to Issue2683 where this was
fixed for Python 3.0.
msg102083 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-04-01 11:35
AFAICT 2.6 and 2.7 behave correctly.
Date User Action Args
2022-04-11 14:56:45adminsetgithub: 49540
2010-04-01 11:35:53floxsetstatus: open -> closed

nosy: + flox
messages: + msg102083

resolution: out of date
stage: resolved
2009-02-17 08:25:43bedacreate