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 randolf.scholz
Recipients randolf.scholz
Date 2021-10-03.19:45:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1633290355.98.0.210301350099.issue45356@roundup.psfhosted.org>
In-reply-to
Content
I noticed some strange behaviour when calling `help` on a class inheriting from a class or having itself @classmethod @property decorated methods.

```python
from time import sleep
from abc import ABC, ABCMeta, abstractmethod

class MyMetaClass(ABCMeta):
    @classmethod
    @property
    def expensive_metaclass_property(cls):
        """This may take a while to compute!"""
        print("computing metaclass property"); sleep(3)
        return "Phew, that was a lot of work!"

    
class MyBaseClass(ABC, metaclass=MyMetaClass):
    @classmethod
    @property
    def expensive_class_property(cls):
        """This may take a while to compute!"""
        print("computing class property .."); sleep(3)
        return "Phew, that was a lot of work!"
    
    @property
    def expensive_instance_property(self):
        """This may take a while to compute!"""
        print("computing instance property ..."); sleep(3)
        return "Phew, that was a lot of work!"

class MyClass(MyBaseClass):
    """Some subclass of MyBaseClass"""
    
help(MyClass)
```

Calling `help(MyClass)` will cause `expensive_class_property` to be executed 4 times (!)

The other two properties, `expensive_instance_property` and `expensive_metaclass_property` are not executed.

Secondly, only `expensive_instance_property` is listed as a read-only property; `expensive_class_property` is listed as a classmethod and `expensive_metaclass_property` is unlisted.

The problem is also present in '3.10.0rc2 (default, Sep 28 2021, 17:57:14) [GCC 10.2.1 20210110]'

Stack Overflow thread: https://stackoverflow.com/questions/69426309
History
Date User Action Args
2021-10-03 19:45:56randolf.scholzsetrecipients: + randolf.scholz
2021-10-03 19:45:55randolf.scholzsetmessageid: <1633290355.98.0.210301350099.issue45356@roundup.psfhosted.org>
2021-10-03 19:45:55randolf.scholzlinkissue45356 messages
2021-10-03 19:45:55randolf.scholzcreate