[ python-Bugs-1162154 ] inspect.getmembers() breaks sometimes

SourceForge.net noreply at sourceforge.net
Sat Mar 12 22:18:20 CET 2005


Bugs item #1162154, was opened at 2005-03-12 21:18
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1162154&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Doug Quale (quale)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect.getmembers() breaks sometimes

Initial Comment:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1162154&group_id=5470


More information about the Python-bugs-list mailing list