Wrapper_iter does not clear error on success

Bug #1155760 reported by Federico G. Schwindt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Acquisition
Fix Released
Undecided
Tres Seaver

Bug Description

_Acquisition.c's Wrapper_iter() doesn't call PyErr_Clear() if PyObject_GetAttr() failed but PySequence_Check() succeeded.
This causes mysterious "AttributeError: __iter__" on otherwise valid code.

The following example shows the issue:

from Acquisition import Implicit
class C(Implicit):
    l = [0, 1, 2, 3, 4]
    def __getitem__(self, i):
        return self.l[i]
a = C()
b = C().__of__(a)
import time
try:
    for n in b:
        time.gmtime()
except AttributeError:
    raise

To fix it simply add the missing PyErr_Clear() after if (PySequence_Check(obj)).

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

Thanks for the report. Test and fix pushed for the 4.0.1 release of Acquisition:

  https://github.com/zopefoundation/Acquisition/commit/7b5c5fd19d6672df4573137487da818c45827b0f

affects: zope2 → acquisition
Changed in acquisition:
assignee: nobody → Tres Seaver (tseaver)
status: New → Fix Committed
Revision history for this message
Tres Seaver (tseaver) wrote :
Changed in acquisition:
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.