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 icecrime
Recipients icecrime
Date 2013-05-24.05:39:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In the Data Model section of the documentation regarding descriptors invokations (, it is said:

    Note that descriptors are only invoked for new style objects or classes (ones that subclass object() or type()).

However, it seems this restriction isn't enforced in practice:

    Python 2.7.4 (default, May 16 2013, 13:28:03)
    [GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> class Desc(object):
    ...     def __get__(self, obj, cls):
    ...             return 'test'
    >>> class A:  # Not inheriting object here
    ...     desc = Desc()
    >>> A().desc

I dived into CPython's code and saw no trace of a test for new-style classes in the descriptor invokation code path (down in classobject.c / instance_getattr2).

Unfortunately, fixing this behavior doesn't seem trivial as class methods appear to be implemented as descriptor themselves. In other words, and from my understanding, restricting descriptor invokation to new-style objects and classes would prevent method calls on old-style classes.
Date User Action Args
2013-05-24 05:39:43icecrimesetrecipients: + icecrime
2013-05-24 05:39:43icecrimesetmessageid: <>
2013-05-24 05:39:43icecrimelinkissue18047 messages
2013-05-24 05:39:42icecrimecreate