--- you can reply above this line --- New issue 130: py.process.cmdexec fails if the out/err contains non-ascii characters http://bitbucket.org/hpk42/py-trunk/issue/130/pyprocesscmdexec-fails-if-the-out-err-contains-non-ascii
Antonio Cuni / antocuni on Wed, 20 Oct 2010 11:30:44 +0200: Description: Consider the following file trouble.py, which just output a non-ascii character to stdout: {{{ # -*- encoding: utf-8 -*- trouble = u'à' print trouble.encode('utf-8') }}} py.process.cmdexec fails if we try to run it: {{{ >>> import py >>> py.process.cmdexec('python trouble.py') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/antocuni/pypy/misc/py-trunk/py/_process/cmdexec.py", line 32, in cmdexec raise ExecutionFailed(status, status, cmd, out, err) py.process.cmdexec.Error: ExecutionFailed: 1 python trouble.py Traceback (most recent call last): File "trouble.py", line 3, in <module> print trouble UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 0: ordinal not in range(128) }}} This happens because cmdexec try to decode stderr and stdout using sys.stdout.encoding or sys.getdefaultencoding(), which not necessarly match the output encoding of the program. Real life use-case: a pypy test invokes gcc, which uses utf-8 characters for quotes. The test fails because of the exception inside cmdexec, even if the test itself completely ignores the stderr. Responsible: hpk42 -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev