A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-April/133842.html below:

[Python-Dev] issue with itertools leads the crash

[Python-Dev] issue with itertools leads the crashMRAB python at mrabarnett.plus.com
Tue Apr 8 18:30:18 CEST 2014
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_per at rambler.ru
> <mailto:kir_per at 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.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4