z.i.adapters.LookupBase.lookup1 inconsistent between Python and C implementations

Bug #910987 reported by Tres Seaver
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zope.interface
Fix Released
Undecided
Tres Seaver

Bug Description

The reference implementation for lookup1 consistently returns the '_default'
if the value returned by 'lookup' is None; the C version only does so on the
first time through: after that, it returns the (cached) None. E.g.:

    from zope.interface.adapters import LookupBase
    class Lookup(LookupBase):
        def _uncached_lookup(self, required, provided, name):
            return None
    lb = Lookup()
    _default = object()
    found = lb.lookup1('A', 'B', 'C', _default)
    assert(found is _default) # OK both in C and Python
    found = lb.lookup1('A', 'B', 'C', _default)
    assert(found is _default) # OK in Python, fails in C

I will attaching a patch which fixes this problem. The patch, as well as
a testcase demonstrating the bug, are also in my branch:

  lp:~tseaver/zope.interface/bettter_unittests

Revision history for this message
Tres Seaver (tseaver) wrote :

Crap, make that branch::

  lp:~tseaver/zope.interface/better_unittests

Revision history for this message
Tres Seaver (tseaver) wrote :

The attached patch makes the behavior of the C implementation of 'lookup1'
consistent with the Python version.

Revision history for this message
Tres Seaver (tseaver) wrote :

Fix landed:

 http://bazaar.launchpad.net/~tseaver/zope.interface/better_unittests/revision/182

That branch should be merged to the trunk by next week or so.

Changed in zope.interface:
assignee: nobody → Tres Seaver (tseaver)
status: New → Fix Committed
Tres Seaver (tseaver)
Changed in zope.interface:
status: Fix Committed → Fix Released
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.