Commit e5253424 authored by Tres Seaver's avatar Tres Seaver

Don't raise AttributeError for '__iter__' if fallback to '__getitem__' succeeds.

LP #1155760.

Cherry-pick 7b5c5fd1 from master.
parent 87ae5171
Changelog
=========
2.13.9 (unreleased)
-------------------
- Don't raise an attribute error for ``__iter__`` if the fallback to
``__getitem__`` succeeds. LP #1155760.
2.13.8 (2011-06-11)
-------------------
......
......@@ -984,6 +984,7 @@ Wrapper_iter(Wrapper *self)
res = NULL;
}
} else if (PySequence_Check(obj)) {
PyErr_Clear();
ASSIGN(res,PySeqIter_New(OBJECT(self)));
} else {
res = PyErr_Format(PyExc_TypeError, "iteration over non-sequence");
......
......@@ -2397,6 +2397,24 @@ def test___parent__aq_parent_circles():
"""
def test__iter__after_AttributeError():
""" See https://bugs.launchpad.net/zope2/+bug/1155760
>>> 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:
... t = time.gmtime()
... except AttributeError:
... raise
"""
import unittest
from doctest import DocTestSuite, DocFileSuite
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment