Message241803
In Python 2, the unicode() constructor accepts bytes argument if it is decodeable with sys.getdefaultencoding().
>>> unicode(b'abc')
u'abc'
>>> import sys
>>> reload(sys)
<module 'sys' (built-in)>
>>> sys.setdefaultencoding("utf-8")
>>> unicode(u'abcäöü'.encode('utf-8'))
u'abc\xe4\xf6\xfc'
In Python 3, the str() constructor does not accept bytes arguments if Python is ran with -bb option. |
|
Date |
User |
Action |
Args |
2015-04-22 13:43:36 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, lemburg, vstinner, ezio.melotti, eryksun |
2015-04-22 13:43:36 | serhiy.storchaka | set | messageid: <1429710216.43.0.46767600072.issue24025@psf.upfronthosting.co.za> |
2015-04-22 13:43:36 | serhiy.storchaka | link | issue24025 messages |
2015-04-22 13:43:35 | serhiy.storchaka | create | |
|