Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subprocess.Popen.communicate does not encode unicode strings #49540

Closed
beda mannequin opened this issue Feb 17, 2009 · 2 comments
Closed

subprocess.Popen.communicate does not encode unicode strings #49540

beda mannequin opened this issue Feb 17, 2009 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@beda
Copy link
Mannequin

beda mannequin commented Feb 17, 2009

BPO 5290
Nosy @florentx

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2010-04-01.11:35:53.124>
created_at = <Date 2009-02-17.08:25:43.403>
labels = ['type-bug', 'library']
title = 'subprocess.Popen.communicate does not encode unicode strings'
updated_at = <Date 2010-04-01.11:35:53.122>
user = 'https://bugs.python.org/beda'

bugs.python.org fields:

activity = <Date 2010-04-01.11:35:53.122>
actor = 'flox'
assignee = 'none'
closed = True
closed_date = <Date 2010-04-01.11:35:53.124>
closer = 'flox'
components = ['Library (Lib)']
creation = <Date 2009-02-17.08:25:43.403>
creator = 'beda'
dependencies = []
files = []
hgrepos = []
issue_num = 5290
keywords = []
message_count = 2.0
messages = ['82304', '102083']
nosy_count = 2.0
nosy_names = ['beda', 'flox']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue5290'
versions = ['Python 2.5']

@beda
Copy link
Mannequin Author

beda mannequin commented Feb 17, 2009

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 bpo-2683 where this was
fixed for Python 3.0.

@beda beda mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 17, 2009
@florentx
Copy link
Mannequin

florentx mannequin commented Apr 1, 2010

AFAICT 2.6 and 2.7 behave correctly.

@florentx florentx mannequin closed this as completed Apr 1, 2010
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants