[zope2-tracker] [Bug 1197508] [NEW] zope.interface.Interface.implementedBy method can corrupt
Michael JasonSmith
1197508 at bugs.launchpad.net
Wed Jul 3 21:08:16 CEST 2013
Public bug reported:
Incorrectly using zope.interface.Interface.implementedBy on an object,
rather than a class, can corrupt the object and make it unusable. Any
time an attribute of the object is accessed, after using implementedBy,
the following error is raised:
File "…/zope/interface/declarations.py", line 338, in implementedByFallback
raise TypeError("ImplementedBy called for non-factory", cls)
TypeError: (TypeError('ImplementedBy called for non-factory', <Folder at >),
<built-in function implementedBy>, (<Folder at >,))
It does not seem to matter which attribute is accessed, or how (getattr
causes the same error as o.attr).
It appears that the root cause of the problem is a side-effect of
zope.interface.declarations.implementedByFallback, which is called by
implementedBy:
cls.__implemented__ = spec
https://github.com/zopefoundation/zope.interface/blob/master/src/zope/interface/declarations.py#L199
At the very least, implementedBy should not have a side-effect. Ever.
This side-effect turns a simple mistake into a major problem:
http://groupserver.org/r/post/5zxOdqzn3dUyweYCAzfahP
I note that others have had similar issues:
http://blog.fourdigits.nl/how-to-break-your-plone-site-with-implementedby
** Affects: zope2
Importance: Undecided
Status: New
** Tags: attribute interface typeerror
--
You received this bug notification because you are a member of Zope 2
Developers, which is subscribed to Zope 2.
https://bugs.launchpad.net/bugs/1197508
Title:
zope.interface.Interface.implementedBy method can corrupt
To manage notifications about this bug go to:
https://bugs.launchpad.net/zope2/+bug/1197508/+subscriptions
More information about the zope2-tracker
mailing list