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 jnsdrtlf
Recipients jnsdrtlf
Date 2019-10-01.12:01:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569931319.11.0.161787180553.issue38337@roundup.psfhosted.org>
In-reply-to
Content
When calling inspect.getmembers on a class that has a property (@property), the property will be called by the getattr call in getmembers.

Example:

import inspect

class Example:
    def __init__(self, var):
        self._var = var
        print('__init__')

    def foo(self, bar):
        print(bar)
        print('foo')

    @property
    def var(self):
        print('Access property')
        return self._var


if __name__ == '__main__':
    ex = Example('Hello')
    print('--- getmembers from instance ---')
    print(inspect.getmembers(ex))
    print('--- getmembers from class    ---')
    print(inspect.getmembers(Example))


Result:

__init__
--- getmembers from instance ---
Access property
[('__class__', <attribute '__class__' of 'object' objects>), ..., ('var', 'Hello')]
--- getmembers from class    ---
[('__class__', <attribute '__class__' of 'object' objects>), ..., ('var', <property object at 0x...>)]


Expected:

__init__
--- getmembers from instance ---
[('__class__', <attribute '__class__' of 'object' objects>), ..., ('var', <property object at 0x...>)]
--- getmembers from class    ---
[('__class__', <attribute '__class__' of 'object' objects>), ..., ('var', <property object at 0x...>)]
History
Date User Action Args
2019-10-01 12:01:59jnsdrtlfsetrecipients: + jnsdrtlf
2019-10-01 12:01:59jnsdrtlfsetmessageid: <1569931319.11.0.161787180553.issue38337@roundup.psfhosted.org>
2019-10-01 12:01:59jnsdrtlflinkissue38337 messages
2019-10-01 12:01:59jnsdrtlfcreate