[issue14847] AttributeError: NoneType has no attribute 'utf_8_decode'

Jason R. Coombs report at bugs.python.org
Wed Jun 6 18:53:19 CEST 2012


Jason R. Coombs <jaraco at jaraco.com> added the comment:

I find that on Python 2.7.3 64-bit Windows, the deletion of locale.encodings is also necessary:

PS C:\Users\jaraco> python
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> b'x'.decode('utf-8')
u'x'
>>> del sys.modules['encodings.utf_8'], sys.modules['encodings']
>>> b'x'.decode('utf-8')
u'x'
>>> ^Z

PS C:\Users\jaraco> python
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> b'x'.decode('utf-8')
u'x'
>>> import locale; del locale.encodings   # Not necessary with python2
>>> del sys.modules['encodings.utf_8'], sys.modules['encodings']
>>> b'x'.decode('utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
AttributeError: 'NoneType' object has no attribute 'utf_8_decode'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14847>
_______________________________________


More information about the Python-bugs-list mailing list