LazyCat.__getitem__() called via __repr__() cripples LazyCat.__add__()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Fix Released
|
Medium
|
Unassigned |
Bug Description
You can add LazyCats together, but only before __repr__() is called or an instance is cast to another sequence type: __getitem__() removes self._seq on line 106 of r40218 in HEAD. To duplicate:
>>> from Products.
>>> lazy1 = LazyCat([ [1,2], ])
>>> lazy1._seq
[[1, 2]]
>>> lazy1 += LazyCat([ [3,4], ])
>>> lazy1._seq
[[1, 2], [3, 4]]
>>> print lazy1 # __repr__ casts to list, calls getitem, removes lazy1._seq
[1, 2, 3, 4]
>>> lazy1._seq #this is bad
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: LazyCat instance has no attribute '_seq'
>>> lazy1 += LazyCat([ [5,6], ]) #this fails because of this bug!
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/
return LazyCat([self, other])
File "/home/
flattened_
AttributeError: LazyCat instance has no attribute '_seq'
agreed - I'll write a test tomorrow and submit patch with test added to tests/testLazyS equences. py