Optimized version of InterfaceBase doesn't use interface's __adapt__

Bug #98488 reported by Ben Artin
2
Affects Status Importance Assigned to Milestone
Zope 3
Won't Fix
Medium
Unassigned
3.2
Won't Fix
Undecided
Unassigned
3.3
Won't Fix
Undecided
Unassigned
3.4
Won't Fix
Medium
Unassigned
zope.interface
Won't Fix
Medium
Unassigned

Bug Description

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.

Tags: bug core
Revision history for this message
Christian Theune (ctheune) wrote :

__adapt__ is not documented in IInterface. However, the tests say that we do this and respect PEP 246 behaviour.

Changed in zope3:
status: New → Confirmed
Tres Seaver (tseaver)
Changed in zope.interface:
status: New → Confirmed
importance: Undecided → Medium
Changed in zope3:
status: Confirmed → Won't Fix
Revision history for this message
Tres Seaver (tseaver) wrote :
Changed in zope.interface:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.