diff options
author | Raymond Hettinger <python@rcn.com> | 2003-05-07 01:28:47 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-05-07 01:28:47 (GMT) |
commit | 686b14d7ad700cfb3d3f0538695f0aa8e6c1b0b8 (patch) | |
tree | e166e888c8dfc6b8257a99d06f7492e52ad91164 /Lib | |
parent | a409f7c491647fe0c256c944d6fe4e9593d15760 (diff) | |
download | cpython-686b14d7ad700cfb3d3f0538695f0aa8e6c1b0b8.zip cpython-686b14d7ad700cfb3d3f0538695f0aa8e6c1b0b8.tar.gz cpython-686b14d7ad700cfb3d3f0538695f0aa8e6c1b0b8.tar.bz2 |
SF bug #730296: Unexpected Changes in list Iterator
Reverted a Py2.3b1 change to iterator in subclasses of list and tuple.
They had been changed to use __getitem__ whenever it had been overriden
in the subclass.
This caused some usabilty and performance problems. Also, it was
inconsistent with the rest of python where many container methods
access the underlying object directly without first checking for
an overridden getter. Users needing a change in iterator behavior
should override it directly.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_types.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 7e238df..1532295 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -256,11 +256,11 @@ def f(): yield i vereq(list(tuple(f())), range(1000)) -# Verify that __getitem__ overrides are recognized by __iter__ +# Verify that __getitem__ overrides are not recognized by __iter__ class T(tuple): def __getitem__(self, key): return str(key) + '!!!' -vereq(iter(T()).next(), '0!!!') +vereq(iter(T((1,2))).next(), 1) print '6.5.3 Lists' # calling built-in types without argument must return empty @@ -453,11 +453,11 @@ a = range(10) a[::2] = tuple(range(5)) vereq(a, [0, 1, 1, 3, 2, 5, 3, 7, 4, 9]) -# Verify that __getitem__ overrides are recognized by __iter__ +# Verify that __getitem__ overrides are not recognized by __iter__ class L(list): def __getitem__(self, key): return str(key) + '!!!' -vereq(iter(L()).next(), '0!!!') +vereq(iter(L([1,2])).next(), 1) print '6.6 Mappings == Dictionaries' |