Message90803
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(). |
|
Date |
User |
Action |
Args |
2009-07-22 07:31:56 | r_mosaic | set | recipients:
+ r_mosaic |
2009-07-22 07:31:56 | r_mosaic | set | messageid: <1248247915.99.0.198197502387.issue6543@psf.upfronthosting.co.za> |
2009-07-22 07:31:53 | r_mosaic | link | issue6543 messages |
2009-07-22 07:31:52 | r_mosaic | create | |
|