New submission from Jason R. Coombs <jar...@jaraco.com>:

I have run into an issue where an attempt to call .decode('utf-8') on a Python 
string results in the error with the following traceback:

File ...
    ''.decode('utf-8')
File "env/lib/python2.6/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'

I've noticed this when running our applications. I've also encountered it when 
installing packages using distribute. With a sufficiently-complicated tree of 
packages to install, distribute 0.6.26 will fail with the error above at 
https://bitbucket.org/tarek/distribute/src/0a45ae3390cd/setuptools/command/easy_install.py#cl-745
 .

Unfortunately, the only case where I've been able to reliably reproduce this 
behavior is with private packages in a very complex arrangement. I tried but 
was not able to create a small script to reproduce the issue.

I see this bug was observed in issue6551, but that only a workaround was 
applied to avoid the symptom, but the underlying cause was never discovered.

Furthermore, I found that I could sometimes reproduce the failure in one line 
of code, but not reproduce it with the same invocation one line prior, with no 
substantial logic in between. In other words, it's not even possible to 
pinpoint the cause because whatever is causing the utf_8 module to become 
finalize is not coincident with where the failures occur.

I'm hesitant to file a bug with Python because the core Python is not 
necessarily implicated, but because this problem emerged in the Python core 
project test suite, I'm inclined to think the issue does lie with Python itself.

Furthermore, it should be very difficult for a Python program to get into a 
situation where ''.decode('utf-8') fails with an AttributeError.

At this point, I could use some help. Is it possible to detect when a module 
(utf_8 in this case) is finalized? I'm realizing now that running python with 
-v might provide some insight, so I'll try that.

----------
components: Library (Lib)
messages: 161032
nosy: jason.coombs
priority: normal
severity: normal
status: open
title: AttributeError: NoneType has no attribute 'utf_8_decode'
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14847>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to