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.

classification
Title: inspect.getmembers() breaks sometimes
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, quale
Priority: normal Keywords:

Created on 2005-03-12 21:18 by quale, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
inspect.getmembers-patch quale, 2005-03-12 21:18 patch for inspect.getmembers()
Messages (2)
msg24570 - (view) Author: Doug Quale (quale) Date: 2005-03-12 21:18
The inspect library module getmembers() method breaks
sometimes when it makes a getattr() call that fails. A
simple example is a slot that doesn't have a value:

 >>> class X(object): __slots__ = 'foo'
 >>> import inspect
 >>> inspect.getmembers(x())
Traceback (most recent call last):
   File "<pyshell#4>", line 1, in -toplevel-
     inspect.getmembers(X())
   File "C:\PYTHON23\lib\inspect.py", line 171, in
getmembers
     value = getattr(object, key)
AttributeError: foo
 >>>

On the PEAK mailing list Phillip Eby suggested wrapping
the gettattr() call in try/except. This seems to work fine.
msg79804 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-01-13 23:39
Fixed in r68596.
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41688
2009-01-13 23:39:37amaury.forgeotdarcsetstatus: open -> closed
resolution: fixed
messages: + msg79804
nosy: + amaury.forgeotdarc
2005-03-12 21:18:20qualecreate