Author: Mark Young <marky1...@gmail.com> Branch: py3k Changeset: r84170:acbc6e257771 Date: 2016-05-01 15:58 -0400 http://bitbucket.org/pypy/pypy/changeset/acbc6e257771/
Log: Update islice to not accept floats to match cpython and update own tests to match islice's reference-holding behavior in cpython. diff --git a/pypy/module/itertools/interp_itertools.py b/pypy/module/itertools/interp_itertools.py --- a/pypy/module/itertools/interp_itertools.py +++ b/pypy/module/itertools/interp_itertools.py @@ -319,7 +319,7 @@ def arg_int_w(self, w_obj, minimum, errormsg): space = self.space try: - result = space.int_w(space.int(w_obj)) # CPython allows floats as parameters + result = space.int_w(w_obj) except OperationError, e: if e.async(space): raise diff --git a/pypy/module/itertools/test/test_itertools.py b/pypy/module/itertools/test/test_itertools.py --- a/pypy/module/itertools/test/test_itertools.py +++ b/pypy/module/itertools/test/test_itertools.py @@ -198,11 +198,8 @@ assert next(it) == x raises(StopIteration, next, it) - # CPython implementation allows floats - it = itertools.islice([1, 2, 3, 4, 5], 0.0, 3.0, 2.0) - for x in [1, 3]: - assert next(it) == x - raises(StopIteration, next, it) + #Do not allow floats + raises(ValueError, itertools.islice, [1, 2, 3, 4, 5], 0.0, 3.0, 2.0) it = itertools.islice([1, 2, 3], 0, None) for x in [1, 2, 3]: @@ -216,8 +213,6 @@ assert list(itertools.islice(range(10), None,None)) == list(range(10)) assert list(itertools.islice(range(10), None,None,None)) == list(range(10)) - # check source iterator is not referenced from islice() - # after the latter has been exhausted import weakref for args in [(1,), (None,), (0, None, 2)]: it = (x for x in (1, 2, 3)) @@ -226,7 +221,7 @@ assert wr() is not None list(it) # exhaust the iterator import gc; gc.collect() - assert wr() is None + assert wr() is not None raises(StopIteration, next, it) def test_islice_dropitems_exact(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit