Issue1785475
Created on 2007-08-31.10:07:05 by mehendran, last changed 2008-09-14.00:47:13 by zyasoft.
File name |
Uploaded |
Description |
Edit |
Remove |
patch.diff
|
mehendran,
2007-08-31.10:07:06
|
patch file |
|
|
msg2875 (view) |
Author: Mehendran (mehendran) |
Date: 2007-08-31.10:07:05 |
|
I have attached the patch file.
This patch will solve the following bugs
1768970
-------
When you iterate over subclass of / sequence like
objects, only the pyget is called previously.
Now it will call __getitem__ method by this patch
so that we can extend sequence like objs and give
our own impln to __getitem__.
https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1768970&group_id=12867
1782565
-------
The output of repr() builtin func on string objects (str, unicode and subclasses of those) / __repr__()
of string objects doesnt match with that of CPython.
https://sourceforge.net/tracker/index.php?func=detail&aid=1782565&group_id=12867&atid=112867
1783868
-------
class weirdstr(str):
def __getitem__(self, index):
return weirdstr(2*str.__getitem__(self,index))
When you call __getitem__ of weirdstr obj, it calls
__getitem__ of str in turn, again from there(str) the
call is made to __getitem__ of weirdstr, thus the call is made back and forth and finally throws
StackOverflowError.
https://sourceforge.net/tracker/index.php?func=detail&aid=1783868&group_id=12867&atid=112867
Test case: Lib/test/test_builtin.py
|
msg3135 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2008-04-08.01:33:48 |
|
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:
|
msg3154 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2008-04-15.01:05:04 |
|
most of the patch for #1782565 (broken repr on str/unicode subclasses)
was incorporated in r4346
It's probably better to log separate issues for separate patch sets so
it's easier to handle cherry picking one part of the whole patch, like I
did here
thanks Mehendran
|
msg3564 (view) |
Author: Jim Baker (zyasoft) |
Date: 2008-09-14.00:47:12 |
|
All issues addressed in this patch have been incorporated or otherwise
fixed in 2.5, specifically __builtins__.filter
|
|
Date |
User |
Action |
Args |
2008-09-14 00:47:13 | zyasoft | set | status: open -> closed resolution: fixed messages:
+ msg3564 nosy:
+ zyasoft |
2008-04-15 01:05:04 | pjenvey | set | messages:
+ msg3154 |
2008-04-08 01:33:48 | pjenvey | set | nosy:
+ pjenvey messages:
+ msg3135 |
2007-08-31 10:07:05 | mehendran | create | |
|