Message3135

Author pjenvey
Recipients mehendran, pjenvey
Date 2008-04-08.01:33:48
SpamBayes Score 0.00528687
Marked as misclassified No
Message-id <1207618428.69.0.882803707791.issue1785475@psf.upfronthosting.co.za>
In-reply-to
Content
What's odd about the patch for #1768970 (use __getitem__ in the iter) is 
that we have to catch KeyErrors to work on Jython (without the catch 
iterating lists doesn't work correctly)

Whereas CPython actually allows KeyErrors to propagate through the 
iterator. I guess CPython is avoiding this by defining different 
iterators for builtins (e.g. list has its own listiterator type)

Python 2.5.1 (r251:54863, Aug 19 2007, 21:02:30) 
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(object):
...     def __getitem__(self, i):
...             raise KeyError
... 
>>> iter(Foo()).next()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in __getitem__
KeyError

with the patch:
Jython 2.3a0 on java1.5.0_13
Type "copyright", "credits" or "license" for more information.
>>> class Foo(object):
...     def __getitem__(self, i):
...             raise KeyError
... 
>>> iter(Foo()).next()
Traceback (innermost last):
  File "<console>", line 1, in ?
StopIteration:
History
Date User Action Args
2008-04-08 01:33:48pjenveysetspambayes_score: 0.00528687 -> 0.00528687
recipients: + pjenvey, mehendran
2008-04-08 01:33:48pjenveysetspambayes_score: 0.00528687 -> 0.00528687
messageid: <1207618428.69.0.882803707791.issue1785475@psf.upfronthosting.co.za>
2008-04-08 01:33:48pjenveylinkissue1785475 messages
2008-04-08 01:33:48pjenveycreate