<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 26, 2014 at 8:52 PM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">There's also the fact that breaking working code in a maintenance release is always dubious, especially when there's no current supported way to get the equivalent behaviour prior to the maintenance release. This is the kind of change that will require a note in the "porting to Python 3.5" section of the What's New, again suggesting strongly that we can't change it in the maintenance releases.</blockquote>
</div><br>It looks like there is more than one bug related to passing negative times as a keyword argument:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">>>> from itertools import *</div>
<div class="gmail_extra">>>> ''.join(repeat('a', times=-4))</div><div class="gmail_extra">Traceback (most recent call last):</div><div class="gmail_extra">  File "<stdin>", line 1, in <module></div>
<div class="gmail_extra">OverflowError: long int too large to convert to int</div><div class="gmail_extra"><br></div><div class="gmail_extra">itertools.repeat() is documented [1] as being equivalent to:</div><div class="gmail_extra">
<br></div><div class="gmail_extra"><pre style="padding:5px;background-color:rgb(238,255,204);color:rgb(51,51,51);line-height:18.527999877929688px;border:1px solid rgb(170,204,153);font-family:monospace,sans-serif;font-size:15.199999809265137px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;text-align:justify">
<span class="" style="color:rgb(0,112,32);font-weight:bold">def</span> <span class="" style="color:rgb(6,40,126)">repeat</span><span class="">(</span><span class="" style="color:rgb(0,112,32)">object</span><span class="">,</span> <span class="">times</span><span class="" style="color:rgb(102,102,102)">=</span><span class="" style="color:rgb(0,112,32);font-weight:bold">None</span><span class="">):</span>
    <span class="" style="color:rgb(64,128,144);font-style:italic"># repeat(10, 3) --> 10 10 10</span>
    <span class="" style="color:rgb(0,112,32);font-weight:bold">if</span> <span class="">times</span> <span class="" style="color:rgb(0,112,32);font-weight:bold">is</span> <span class="" style="color:rgb(0,112,32);font-weight:bold">None</span><span class="">:</span>
        <span class="" style="color:rgb(0,112,32);font-weight:bold">while</span> <span class="" style="color:rgb(0,112,32);font-weight:bold">True</span><span class="">:</span>
            <span class="" style="color:rgb(0,112,32);font-weight:bold">yield</span> <span class="" style="color:rgb(0,112,32)">object</span>
    <span class="" style="color:rgb(0,112,32);font-weight:bold">else</span><span class="">:</span>
        <span class="" style="color:rgb(0,112,32);font-weight:bold">for</span> <span class="">i</span> <span class="" style="color:rgb(0,112,32);font-weight:bold">in</span> <span class="" style="color:rgb(0,112,32)">range</span><span class="">(</span><span class="">times</span><span class="">):</span>
            <span class="" style="color:rgb(0,112,32);font-weight:bold">yield</span> <span class="" style="color:rgb(0,112,32)">object</span></pre></div><div class="gmail_extra">The behavior of the CPython implementation is clearly wrong.  If there are people relying on it - they already have code that would break in other implementations.  (I would say not accepting None for times is a bug as well if you read the docs literally.)</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">When implementation behavior differs from documentation it is a bug by definition and a fix should go in bug-fix releases.  Reproducing old behavior is fairly trivial using an old_repeat(object, *args, **kwds) wrapper to distinguish between arguments passed positionally and by keyword.  However, I seriously doubt that anyone would need that. </div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">[1] <a href="http://docs.python.org/3/library/itertools.html#itertools.repeat">http://docs.python.org/3/library/itertools.html#itertools.repeat</a></div>
<div class="gmail_extra"><br></div></div></div>