This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author liori
Recipients liori
Date 2009-04-29.11:58:29
SpamBayes Score 6.5055356e-10
Marked as misclassified No
Message-id <1241006313.4.0.792016858663.issue5876@psf.upfronthosting.co.za>
In-reply-to
Content
Invitation... (Debian Sid, gnome-terminal with pl_PL.UTF8 locales)

Python 2.5.4 (r254:67916, Feb 17 2009, 20:16:45) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Lets create some class...

>>> class T(object):
...     def __repr__(self): return u'あみご'
... 

Does its repr() work?

>>> T().__repr__()
u'\u3042\u307f\u3054'
>>> print T().__repr__()
あみご

But when it is implicitly called, it doesnt?!

>>> T()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position
0-2: ordinal not in range(128)
>>> print T()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position
0-2: ordinal not in range(128)


Encoding:

>>> import sys
>>> sys.stdin.encoding
'UTF-8'
>>> sys.stdout.encoding
'UTF-8'

Workaround for now:

>>> class T(object):
...     def __repr__(self): return u'あみご'.encode('utf-8')
...
History
Date User Action Args
2009-04-29 11:58:33liorisetrecipients: + liori
2009-04-29 11:58:33liorisetmessageid: <1241006313.4.0.792016858663.issue5876@psf.upfronthosting.co.za>
2009-04-29 11:58:31liorilinkissue5876 messages
2009-04-29 11:58:29lioricreate