You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: itertools.count() accepts None for start and step #1251
itertools.count(None) and itertools.count(0, None) return count(0) on GraalPy. CPython raises TypeError: a number is required, since only an omitted start or step takes the default.
Operating system
macOS
CPU architecture
ARM64
GraalPy version
master a3009f9 (Python 3.13.14); also reproduced on 25.1.3 (Python 3.12.8)
The keyword forms count(start=None) and count(step=None) behave the same. A non-number other than None, such as count('a'), already raises the TypeError.
Root Cause
CountBuiltins.CountNode declares start and step with useDefaultForNone = true (CountBuiltins.java#L101-L104), so an explicit None becomes 0 or 1 before the PyNumberCheckNode checks (#L123-L128). CPython's clinic defaults only a missing argument (c_default="NULL"), and itertools_count_impl passes None to PyNumber_Check (itertoolsmodule.c#L4022-L4026).
Fix Suggestion
Drop useDefaultForNone = true from both @ArgumentClinic annotations, so the defaults apply only to an omitted argument.
Activity