[ python-Bugs-1225107 ] inspect.isclass() fails with custom __getattr__
SourceForge.net
noreply at sourceforge.net
Tue Jun 21 22:20:02 CEST 2005
Bugs item #1225107, was opened at 2005-06-21 14:20
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=1225107&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Kloth (jkloth)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect.isclass() fails with custom __getattr__
Initial Comment:
inspect.isclass() can return True for instances of classes
which define a __getattr__ method. For example:
>>> class Namespace(unicode):
... def __getattr__(self, attr):
... return '<%s>' % (self + attr)
...
>>> inspect.isclass(Namespace('foo'))
True
Changing inspect.isclass() to:
return isinstance(object, (types.ClassType, type))
solves this issue.
The check for __bases__ is no longer need due to
type/class unification.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1225107&group_id=5470
More information about the Python-bugs-list
mailing list