Message 241803 - Python tracker
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.