[pypy-issue] [issue783] subprocess cannot handle unicode args

Marko Kreen tracker at bugs.pypy.org
Wed Jul 6 16:31:27 CEST 2011

New submission from Marko Kreen <markokr at gmail.com>:

subprocess should use LANG encoding when preparing args, but instead
uses 'ascii', which throws error on non-ascii string.

Attached code works across Python 2.4 .. 3.2 and Jython, but crashes on PyPy:

$ pypy ./ucode.py 
Traceback (most recent call last):
  File "app_main.py", line 53, in run_toplevel
  File "./ucode.py", line 12, in <module>
    p = subprocess.Popen(cmd)
  File "/opt/apps/pypy/lib-python/modified-2.7/subprocess.py", line 672, in __init__
    errread, errwrite)
  File "/opt/apps/pypy/lib-python/modified-2.7/subprocess.py", line 1206, in
    raise child_exception
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2:
ordinal not in range(128)

$ echo $LANG
$ pypy --version
Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
[PyPy 1.5.0-alpha0 with GCC 4.4.3]

files: ucode.py
messages: 2742
nosy: mkz, pypy-issue
priority: bug
status: unread
title: subprocess cannot handle unicode args

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list