Issue1094757

classification
Title: enumerate() implementation
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: bzimmer Nosy List: bzimmer, dsuch
Priority: normal Keywords: patch

Created on 2005-01-03.02:45:07 by dsuch, last changed 2005-06-03.20:30:16 by dsuch.

Files
File name Uploaded Description Edit Remove
PyEnum.java dsuch, 2005-01-03.02:45:08
__builtin__.java.patch dsuch, 2005-01-03.02:48:00 Patch for enumerate()
enumerate_new_style.diff dsuch, 2005-05-25.09:28:37 Make enumerate a new-style type.
test_enumerate_new_style.py dsuch, 2005-05-25.09:30:07
enumerate.expose dsuch, 2005-05-25.09:30:46
__builtin__.java.patch dsuch, 2005-06-03.20:29:49 new-style
test_enumerate.py.patch dsuch, 2005-06-03.20:30:16 new-style
Messages
msg2399 (view) Author: Dariusz Suchojad (dsuch) Date: 2005-01-03.02:45:07
This patch implements most of the functionality of PEP
279 The enumerate() built-in function. It can't be
fully implemented in this moment, because of:

Jython 2.2aNewstyle on java1.4.2_06 (JIT: null)
Type "copyright", "credits" or "license" for more
information.
>>> class C(enumerate):pass
...
Traceback (innermost last):
  File "<console>", line 1, in ?
TypeError: base is not a class object:
'reflectedfunction' object
>>>

I'm willing to develop it further but there must be a
way to subclass builtin base types first (and it seems
to be a matter of days now :-)

It passes most of the test from test_enumerate.py of
Python 2.3.4 (included in attachment) - I commented out
those requiring sets module and subclassing builtins.
msg2400 (view) Author: Brian Zimmer (bzimmer) Date: 2005-02-19.20:53:57
Logged In: YES 
user_id=37674

What's the purpose for building a new list for each 
__getattr__("__methods__")?

I'd also prefer the name be PyEnumerate for consistency with PyIterator 
and PyGenerator.  I've changed it as such locally.

Other than that we'll wait for the subclassing of it until the new-style work 
is complete.  I'll commit this as the majority of it passes the tests.
msg2401 (view) Author: Dariusz Suchojad (dsuch) Date: 2005-05-25.09:28:37
Logged In: YES 
user_id=954779

I'm sending a patch to make enumerate a new-style class, so
I'm reopening this.

enumerate now passes all non-sets related tests (file
test_enumerate_subclass.py) except for one. I'm not sure why
it's happening that this test failes, will ask on
jython-dev@ list and post an URL for discussion here.
msg2402 (view) Author: Brian Zimmer (bzimmer) Date: 2005-06-03.02:20:43
Logged In: YES 
user_id=37674

Should any of the files be removed?  There are two different test cases 
which seem to differ only slightly.
msg2403 (view) Author: Dariusz Suchojad (dsuch) Date: 2005-06-03.10:12:17
Logged In: YES 
user_id=954779

test_enumerate.py is an old test, I'm removing it. 	
test_enumerate_new_style.py is a new one, it also checks
enumerate's new-styleness.

I can see you have commited test_enumerate.py into CVS, but
the file should actually be test_enumerate_new_style.py,
sorry for the confusion.
msg2404 (view) Author: Brian Zimmer (bzimmer) Date: 2005-06-03.11:22:15
Logged In: YES 
user_id=37674

I could not get the test_enumerate_new_style.py to test successfully so 
I did the other one.  Can you test the commits I made with the correct 
test file and add any diffs to this patch report?  I want to make sure 
we're including the correct files.  Thanks.
msg2405 (view) Author: Dariusz Suchojad (dsuch) Date: 2005-06-03.20:29:49
Logged In: YES 
user_id=954779

It appears that I forgot to attach a patch to
__builtin__.java, and that's why the tests were failing.
Attaching "__builtin__.java.patch (new-style)" which should
help. I'm also sending "test_enumerate.py.patch (new-style),
which checks correctness of new-style type related behaviour.

Please note that one test (in
EnumerateTestCase.test_basicfunction, I commented it out)
still fails, and I don't fully understand the reason. This
also applies to other new-style types, I asked about it here
http://sf.net/mailarchive/forum.php?thread_id=7362541&forum_id=5587,
no reply yet...
History
Date User Action Args
2005-01-03 02:45:07dsuchcreate