[Interface-dev] ClassProvides vs. inspect.getmembers

Thomas Lotze thomas at thomas-lotze.de
Wed Jul 8 13:17:20 EDT 2009


I just ran into trouble with the following:

>>> import zope.interface
>>> import inspect
>>> class I(zope.interface.Interface):
...     pass
... 
>>> class Foo(object):
...     zope.interface.implements(I)
... 
>>> class Bar(Foo):
...     pass
... 
>>> inspect.getmembers(Bar)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/opt/Python-2.5/lib/python2.5/inspect.py", line 206, in getmembers
    value = getattr(object, key)
AttributeError: __provides__

This is due to the fact that the ClassProvides declaration deliberately
raises a AttributeError when queried on a subclass of the class it belongs
to. I'd like to know people's opinions on whether to change this
behaviour, perhaps to returning None or something empty in order not to
break basic inspection.

-- 
Thomas





More information about the Interface-dev mailing list