Python 3.0 crashes displaying Unicode at interactive prompt

John Machin sjmachin at lexicon.net
Sat Dec 13 15:28:14 EST 2008


Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> x = u'\u9876'
>>> x
u'\u9876'

# As expected

Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit
(Intel)] on win 32
Type "help", "copyright", "credits" or "license" for more information.
>>> x = '\u9876'
>>> x
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python30\lib\io.py", line 1491, in write
    b = encoder.encode(s)
  File "C:\python30\lib\encodings\cp850.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u9876' in
position
1: character maps to <undefined>

# *NOT* as expected (by me, that is)

Is this the intended outcome?



More information about the Python-list mailing list