Optimized version of InterfaceBase doesn't use interface's __adapt__
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(
print Test.__adapt__(1) # prints 17
Test(1) # Generates an exception
This is not how InterfaceBasePy
Changed in zope.interface: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
Changed in zope3: | |
status: | Confirmed → Won't Fix |
__adapt__ is not documented in IInterface. However, the tests say that we do this and respect PEP 246 behaviour.