Any idea why this is happening when encoding is explicitly specified?
In [23]: import sys
In [24]: sys.getdefaultencoding()
Out[24]: 'utf-8'
In [25]: str(b'', encoding='utf-8') == ''
Out[25]: True
In [26]: str('') == ''
Out[26]: True
In [27]: str('', encoding='utf-8') == ''
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-27-e187972042f8> in <module>()
----> 1 str('', encoding='utf-8') == ''
TypeError: decoding str is not supported
According to the docs of str:
encoding defaults to sys.getdefaultencoding()
str('')decodes using the default encoding. It doesn't. It doesn't decode at all.