This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients barry, docs@python
Date 2014-01-14.19:46:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1389728767.16.0.141259686696.issue20261@psf.upfronthosting.co.za>
In-reply-to
Content
I've been debugging a crash in nose 1.3.0, the root cause of which turned out to be an instance containing an attribute which itself was an instance of the following class (boiled down):

class Picky:
    def __getstate__(self):
        return {}
    def __getattr__(self, attr):
        return None

This crashes with a TypeError in Python 2.7 and Python 3 (albeit with slightly different tracebacks; and Python 3 is more difficult to debug because the TypeError doesn't include any useful information).

TypeError: 'NoneType' object is not callable

The culprit is __getattr__() returning None.  In Python 3 for example, pickle tries to get the object's __reduce_ex__() function and then call it.

The problem is the (IMHO) bogus __getattr__() and I'm not sure why nose has this.  But I wonder if the pickle documentation should warn against this kind of thing.

This isn't a bug in Python - the crash makes sense when you understand the implications, but perhaps a warning in the docs would have helped prevent this nose bug in the first place.  I suppose I could also see improving _pickle.c to provide some additional feedback on the offending attribute, but that's probably more difficult.

It's okay to close this as won't fix if we can't think of appropriate wording.  It's enough that there's a record of this issue for search engines now.
History
Date User Action Args
2014-01-14 19:46:07barrysetrecipients: + barry, docs@python
2014-01-14 19:46:07barrysetmessageid: <1389728767.16.0.141259686696.issue20261@psf.upfronthosting.co.za>
2014-01-14 19:46:07barrylinkissue20261 messages
2014-01-14 19:46:06barrycreate