[issue6543] traceback presented in wrong encoding
Fan Decheng
report at bugs.python.org
Wed Jul 22 09:31:56 CEST 2009
New submission from Fan Decheng <fandecheng at gmail.com>:
traceback information is wrongly encoded.
Steps to reproduce:
1. Use a version of Windows that supports CP936 (Simplified Chinese) as
the default encoding.
2. Create a directory containing Chinese characters. Such as C:\测试
3. In the directory create a python file such as C:\测试\test.py
4. In the python file enter the following lines
import traceback
try:
aaa # create a non-existent name
except Exception as ex:
traceback.print_exc()
5. Run the program with this command line (remember to use full path to
the test.py file):
C:\Python31\python.exe C:\测试\test.py
6. See the output.
Expected result:
There is correct output without encoding problems. Such as:
Traceback (most recent call last):
File "C:\测试\test.py", line 3, in <module>
NameError: name 'aaa' is not defined
Actual result:
UTF-8 encoded string is decoded using CP936 so the output is incorrect.
Traceback (most recent call last):
File "C:\娴嬭瘯\test.py", line 3, in <module>
NameError: name 'aaa' is not defined
Additional information:
In Python 3.0, such test would generate:
File "<decoding error>", line 221, in main
In Python 3.1, the test generates the output mentioned in the repro
steps. As I tried traceback.format_exc(), it seems the original
characters 测试 have become three Unicode characters when returned by
format_exc().
----------
components: Interpreter Core
messages: 90803
nosy: r_mosaic
severity: normal
status: open
title: traceback presented in wrong encoding
type: behavior
versions: Python 3.1
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6543>
_______________________________________
More information about the Python-bugs-list
mailing list