[issue19145] Inconsistent behaviour in itertools.repeat when using negative times

Vajrasky Kok report at bugs.python.org
Wed Oct 2 17:23:16 CEST 2013


New submission from Vajrasky Kok:

>>> from itertools import repeat
>>> repeat(2, -10).__length_hint__()
0
>>> repeat(2, times=-10).__length_hint__()
18446744073709551606
>>> repeat(2, times=-10)
repeat(2, -10)
>>> repeat(2, -10)
repeat(2, 0)

Hereby, I attached two alternatives of patch to make the behaviour consistent.

The first one makes the negative number parameter/keyword ALWAYS means endless.

----------
components: Library (Lib)
files: fix_itertools_repeat_negative_number_means_endless.patch
keywords: patch
messages: 198849
nosy: vajrasky
priority: normal
severity: normal
status: open
title: Inconsistent behaviour in itertools.repeat when using negative times
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file31943/fix_itertools_repeat_negative_number_means_endless.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19145>
_______________________________________


More information about the Python-bugs-list mailing list