Message15412
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. |
|
Date |
User |
Action |
Args |
2007-08-23 14:12:23 | admin | link | issue718532 messages |
2007-08-23 14:12:23 | admin | create | |
|