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 serhiy.storchaka
Recipients kbk, ned.deily, roger.serwy, serhiy.storchaka, terry.reedy, tim.peters
Date 2013-11-04.08:40:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1383554445.59.0.532584449316.issue19481@psf.upfronthosting.co.za>
In-reply-to
Content
I suppose this is related to pickling.

I were puzzled why it works with bytearray subclasses. But now I investigated that print() implicitly converts str and bytearray subclasses to str and left unicode subclasses as is. You can reproduce this bug for str and bytearray subclasses if use sys.stdout.write() instead of print().

Here is a patch for 2.7 which fixes the issue for str and bytearray subclasses too. 3.x needs patch too.

>>> class U(unicode): pass

>>> class S(str): pass

>>> class BA(bytearray): pass

>>> import sys
>>> sys.stdout.write(u'\u20ac')
€
>>> sys.stdout.write('\xe2\x82\xac')
€
>>> sys.stdout.write(bytearray('\xe2\x82\xac'))
€
>>> sys.stdout.write(U(u'\u20ac'))
€
>>> sys.stdout.write(S('\xe2\x82\xac'))
€
>>> sys.stdout.write(BA('\xe2\x82\xac'))
€
History
Date User Action Args
2013-11-04 08:40:45serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, terry.reedy, kbk, ned.deily, roger.serwy
2013-11-04 08:40:45serhiy.storchakasetmessageid: <1383554445.59.0.532584449316.issue19481@psf.upfronthosting.co.za>
2013-11-04 08:40:45serhiy.storchakalinkissue19481 messages
2013-11-04 08:40:45serhiy.storchakacreate