[zope.interface bug] Re: [Zope-dev] "zope.interface" confuses Python

Dieter Maurer dieter at handshake.de
Mon Jan 7 14:35:22 EST 2008


Dieter Maurer wrote at 2008-1-7 17:55 +0100:
>Yesterday, I released "dm.zdoc" and today I find problems.
>
>The analysis revealed:
>
>  The class "webdav.EtagSupport.EtagSupport" has initially no
>  attributes "__provides__" and "__providedBy__".
>
>  For still unknown reasons, it suddenly gets these attributes.
>  "__provides__" is a "zope.interface.declarations.ClassProvides".
>  Therefore, I expect that Zope 3 or "five" is responsible
>  for these additions.
>
>  "EtagSupport" is in the mro of "ManagableIndex".
>  But nevertheless, "ManagableIndex.__provides__" results in
>  an "AttributeError".
>
>Here is a transscript reproducing the problem:
>
>>>> import App.FindHomes
>>>> from webdav.EtagSupport import EtagSupport
>>>> EtagSupport.__provides__
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>AttributeError: class EtagSupport has no attribute '__provides__'
>>>> from Products.ManagableIndex.ManagableIndex import ManagableIndex
>/usr/local/lib/python24.zip/whrandom.py:38: DeprecationWarning: the whrandom module is deprecated; please use the random module
>  DeprecationWarning)
>>>> EtagSupport.__provides__
><zope.interface.declarations.ClassProvides object at 0x40b5566c>
>>>> ManagableIndex.__provides__
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>AttributeError: __provides__
>>>> from inspect import getmro
>>>> EtagSupport in getmro(ManagableIndex)
>True
>
>
>Any ideas?

I think I understand the behavior -- and I think it is a "zope.interface"
bug.

Under some circumstances "zope.interface" adds a "__provides__" descriptor
to a class. The descriptor is implemented in
"zope/interface/_zope_interface_coptimizations.c" and called "CPB_descr_get".

While "__implements__" is inherited by derived classes,
the inherited "__provides__" refuses to work for a derived class
and raises "AttributeError: __provides__" instead,
the AttriuteError, I observe....

I will try to make my failure independent of "ManagableIndex"
and then file a bug report.



-- 
Dieter


More information about the Zope-Dev mailing list