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 eric.snow
Recipients eric.snow
Date 2012-10-16.18:24:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In Objects/typeobject.c, reduce_2() makes _PyObject_GetAttrId() calls to pull some methods for the object in question.  This is a problem when the object's type defines __getattr__() or __getattribute__() and returns something like None when the attribute is not found:

from copy import deepcopy

class Spam(dict):
    def __getattr__(self, name):
        # defaults to None
        return self.get(name)


While we could do a check on the result of _PyObject_GetAttrId() to make sure it is callable, the better solution would be to look up the methods on the object's type rather than on the object.  Doing so falls in line with the specified pattern for special method lookup [1].  I'm guessing there are a few other related places in typeobject.c that have the same problem which could be fixed in the same way.

I'm marking this as a bug rather than a feature since it is a deviation from the specification for special methods.

Date User Action Args
2012-10-16 18:24:54eric.snowsetrecipients: + eric.snow
2012-10-16 18:24:54eric.snowsetmessageid: <>
2012-10-16 18:24:53eric.snowlinkissue16251 messages
2012-10-16 18:24:53eric.snowcreate