[pypy-svn] r75607 - in pypy/branch/fast-forward/pypy/module/__builtin__: . test
benjamin at codespeak.net
benjamin at codespeak.net
Fri Jun 25 22:18:38 CEST 2010
Author: benjamin
Date: Fri Jun 25 22:18:36 2010
New Revision: 75607
Modified:
pypy/branch/fast-forward/pypy/module/__builtin__/functional.py
pypy/branch/fast-forward/pypy/module/__builtin__/test/test_builtin.py
Log:
give enumerate a start argument
Modified: pypy/branch/fast-forward/pypy/module/__builtin__/functional.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/__builtin__/functional.py (original)
+++ pypy/branch/fast-forward/pypy/module/__builtin__/functional.py Fri Jun 25 22:18:36 2010
@@ -374,10 +374,11 @@
self.w_iter = w_iter
self.w_index = w_start
- def descr___new__(space, w_subtype, w_iterable):
+ def descr___new__(space, w_subtype, w_iterable, start=0):
self = space.allocate_instance(W_Enumerate, w_subtype)
- self.__init__(space.iter(w_iterable), space.wrap(0))
+ self.__init__(space.iter(w_iterable), space.wrap(start))
return space.wrap(self)
+ descr___new__.unwrap_spec = [ObjSpace, W_Root, W_Root, int]
def descr___iter__(self, space):
return space.wrap(self)
Modified: pypy/branch/fast-forward/pypy/module/__builtin__/test/test_builtin.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/__builtin__/test/test_builtin.py (original)
+++ pypy/branch/fast-forward/pypy/module/__builtin__/test/test_builtin.py Fri Jun 25 22:18:36 2010
@@ -186,7 +186,8 @@
raises(StopIteration, enum.next)
raises(TypeError, enumerate, 1)
raises(TypeError, enumerate, None)
-
+ enum = enumerate(range(5), 2)
+ assert list(enum) == zip(range(2, 7), range(5))
def test_xrange_args(self):
## # xrange() attributes are deprecated and were removed in Python 2.3.
More information about the Pypy-commit
mailing list