New submission from Jonas Drotleff <jonas.drotl...@gmail.com>:
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...>)] ---------- components: Library (Lib) messages: 353688 nosy: jnsdrtlf priority: normal severity: normal status: open title: inspect: getmembers calls properties type: behavior versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38337> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com