[New-bugs-announce] [issue4599] Strings undisplayable with repr
Michael Foord
report at bugs.python.org
Mon Dec 8 22:08:26 CET 2008
New submission from Michael Foord <michael at voidspace.org.uk>:
In Python 3 strings with non-ascii characters are undisplayable (even
with repr) in the default interactive interpreter on Windows and Mac.
Shouldn't the repr use escapes as with previous versions of Python?
Python 2.6
Python 2.6 (trunk:66714:66715M, Oct 1 2008, 18:36:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> d = u'\u20ac'
>>> d
u'\u20ac'
Python 3
Python 3.0 (r30:67503, Dec 6 2008, 21:14:27)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> d = '\u20ac'
>>> d
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/io.py",
line 1491, in write
b = encoder.encode(s)
File
"/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/encodings/ascii.py",
line 22, in encode
return codecs.ascii_encode(input, self.errors)[0]
UnicodeEncodeError: 'ascii' codec can't encode character '\u20ac' in
position 1: ordinal not in range(128)
>>> repr(d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/io.py",
line 1491, in write
b = encoder.encode(s)
File
"/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/encodings/ascii.py",
line 22, in encode
return codecs.ascii_encode(input, self.errors)[0]
UnicodeEncodeError: 'ascii' codec can't encode character '\u20ac' in
position 2: ordinal not in range(128)
>>>
----------
components: Interpreter Core, Macintosh, Windows
messages: 77341
nosy: mfoord
severity: normal
status: open
title: Strings undisplayable with repr
versions: Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4599>
_______________________________________
More information about the New-bugs-announce
mailing list