[Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)

Steven D'Aprano steve at pearwood.info
Sat Feb 1 22:50:10 CET 2014


On Sat, Feb 01, 2014 at 10:20:24PM +1000, Nick Coghlan wrote:
> On 1 February 2014 16:04, Ethan Furman <ethan at stoneleaf.us> wrote:
> > So we only fix bugs that don't work at all?  By which I mean, if the
> > interpreter doesn't crash, we don't fix it?
> 
> No, we make a judgment call based on the severity and likelihood of
> encountering the bug, the consequences of encountering it, and the
> difficulty of working around it after you *do* encounter it.

Nice summary Nick, however there is one slight error:

> In this case:
> 
> * Likelihood: low (using keyword arguments with simple APIs like this
> is not a common idiom, and you have to specifically pass -1 to trigger
> misbehaviour)


It's not just -1, its any negative value:

py> from itertools import repeat
py> it = repeat('a', -17)  # Correct.
py> next(it)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration
py> it = repeat('a', times=-17)  # Bug, repeats forever.
py> next(it)
'a'


[...]
> Conclusion:
> 
> * add the new, supported feature that provides equivalent
> functionality (accepting None) in 3.5
> 
> * deprecate the problematic behaviour in 3.5 and then start treating
> it as equivalent to the positional argument handling in 3.6+

Seems reasonable to me.

Thanks again for the nice summary.


-- 
Steven


More information about the Python-Dev mailing list