Message202096
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'))
€ |
|
Date |
User |
Action |
Args |
2013-11-04 08:40:45 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, tim.peters, terry.reedy, kbk, ned.deily, roger.serwy |
2013-11-04 08:40:45 | serhiy.storchaka | set | messageid: <1383554445.59.0.532584449316.issue19481@psf.upfronthosting.co.za> |
2013-11-04 08:40:45 | serhiy.storchaka | link | issue19481 messages |
2013-11-04 08:40:45 | serhiy.storchaka | create | |
|