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 sschwarzer
Recipients
Date 2003-04-09.20:01:14
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
inspect.isclass(class_instance) fails if the
corresponding class uses a "wildcard" implementation of
__getattr__.

Example:

Python 2.2.2 (#1, Nov 13 2002, 22:53:57) 
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for
more information.
>>> import inspect
>>> class X:
...     def __getattr__(self, name):
...             if name == 'foo':
...                     return 1   
...             if name == 'bar':
...                     return 2
...             else:
...                     return "default"
... 
>>> x = X()
>>> inspect.isclass(x)
1

The problematic expression in inspect.isclass is
hasattr(object, '__bases__') which returns a true value.
History
Date User Action Args
2007-08-23 14:12:23adminlinkissue718532 messages
2007-08-23 14:12:23admincreate