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

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Jan 27 05:40:33 CET 2014


On Sun, Jan 26, 2014 at 11:26 PM, Vajrasky Kok
<sky.kok at speaklikeaking.com>wrote:

> In case we are taking "not backporting anything at all" road, what is
> the best fix for the document?
>
> Old
> >>> itertools.repeat.__doc__
> 'repeat(object [,times]) -> create an iterator which returns the
> object\nfor the specified number of times.  If not specified, returns
> the object\nendlessly.'
>

I would say no fix is needed for this doc because the signature suggests
(correctly) that passing times by keyword is not supported.

The following behavior further supports this interpretation.

>>> from itertools import *
>>> ''.join(repeat('a', times=-4))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: long int too large to convert to int

The ReST documentation may benefit from an addition of a warning that
behavior of repeat() is "undefined" when times is passed by keyword.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140126/66e8ea71/attachment.html>


More information about the Python-Dev mailing list