[ZCM] [ZC] 2286/ 2 Reject "Optimized version of InterfaceBase doesn't use interface's __adapt__"

"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Tue, 27 Feb 2007 22:00:34 -0500
Newsgroups gmane.comp.web.zope.devel.collector-monitor
Message-ID <[email protected]>
Issue #2286 Update (Reject) "Optimized version of InterfaceBase doesn't use interface's __adapt__"
 Status Rejected, Zope/bug medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2286

==============================================================
= Reject - Entry #2 by ajung on Feb 27, 2007 10:00 pm

 Status: Pending => Rejected

This is a Zope 3 core issue. Please use the Zope 3 collector.
________________________________________
= Request - Entry #1 by bromine on Feb 27, 2007 9:56 pm

According to zope.interface documentation, the __call__ of an interface should use __adapt__ in the interface to attempt to adapt the object. This is not so with the optimized C version of InterfaceBase:

from zope.interface import Interface
class Test(Interface):
    pass
def adapt(*args, **kwargs):
    return 17
from new import instancemethod
Test.__adapt__ = instancemethod(adapt, Test)
print Test.__adapt__(1) # prints 17
Test(1) # Generates an exception

This is not how InterfaceBasePy.__call__ behaves -- it uses interface.__adapt__, which can be customized for each interface. This discrepancy between InterfaceBasePy and the C-optimized InterfaceBase should be eliminated; I believe that the behavior of InterfaceBase should change to match that of InterfaceBasePy.

==============================================================