On 2014-04-08 16:31, Brett Cannon wrote:
Please a file a bug at bugs.python.org <http://bugs.python.org>,
otherwise this is most likely going to get lost track of.

On Tue Apr 08 2014 at 11:30:15 AM, Kirill <kir_...@rambler.ru
<mailto:kir_...@rambler.ru>> wrote:

        issue with itertools leads the crash


          The following code leads to system failure and crash on Ubuntu
        12.04.3 with Python 2.7.6.

        import itertools

        r = range (1,10)

        r[1:9:2] = itertools.cycle([0])

If the RHS yields too few, e.g. 3, you'll get:

ValueError: attempt to assign sequence of size 3 to extended slice of size 4

If it yields too many, e.g. 10, you'll get:

ValueError: attempt to assign sequence of size 10 to extended slice of size 4

It'll try to get all the values from the generator, which, of course,
will never happen with 'cycle'. It'll just consume more and more
memory, until it fails.

The fix would be to complain of raise StopIteration doesn't occur after
N+1 yields, where N is the number of values needed by the LHS.

Something for Python 3.5, maybe? :-)

It's not going to happen in Python 2.7; that's the end of the Python 2
series, and it's getting security fixes only.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to