[pypy-issue] [issue801] itertools/next(?) behavior incompatible with CPython

Yesudeep Mangalapilly tracker at bugs.pypy.org
Thu Jul 21 01:29:43 CEST 2011


New submission from Yesudeep Mangalapilly <yesudeep at gmail.com>:

I believe either the itertools module or the next builtin
does not share exactly the same behavior with CPython.
Here's an extract from a library I'm working on: 

Sample Program
==============

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    from itertools import islice

    def eat(iterator, n):
        next(islice(iterator, n, n), None)
    
    it = iter([1, 2, 3] * 4)
    eat(it, 9)
    x = tuple(it)
    print(x)
    assert x == (1, 2, 3)

Python 2.x or 3.x (expected behavior)
=====================================

    (1, 2, 3)

PyPy 1.5 (got behavior)
=======================

    (1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3)
    Traceback (most recent call last):
      File "app_main.py", line 53, in run_toplevel
      File "foobar.py", line 13, in <module>
        assert x == (1, 2, 3)
    AssertionError

----------
messages: 2831
nosy: pypy-issue, yesudeep
priority: bug
release: 1.5
status: unread
title: itertools/next(?) behavior incompatible with CPython

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue801>
________________________________________


More information about the pypy-issue mailing list