Skip to content

Setting a string to start and step argument of itertools.count() gets a wrong error message #135284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hyperkai opened this issue Jun 9, 2025 · 1 comment
Labels
extension-modules C modules in the Modules dir invalid type-bug An unexpected behavior, bug, or error

Comments

@hyperkai
Copy link

hyperkai commented Jun 9, 2025

Bug report

Bug description:

Setting a string to start and step argument of itertools.count() gets the error message as shown below:

from itertools import count

print(count(start='Hello')) # Error
print(count(step='World')) # Error

TypeError: a number is required

But setting a boolean value to start and step argument works as shown below:

from itertools import count

print(count(start=True)) # count(1)
print(count(step=False)) # count(0, False)

So, the error message should be the same as the one of range() as shown below:

print(range('Hello')) # Error

TypeError: 'str' object cannot be interpreted as an integer

CPython versions tested on:

3.13

Operating systems tested on:

Windows

@hyperkai hyperkai added the type-bug An unexpected behavior, bug, or error label Jun 9, 2025
@skirpichev skirpichev added invalid extension-modules C modules in the Modules dir labels Jun 9, 2025
@skirpichev
Copy link
Contributor

But booleans are integers (subclass). Error message looks correct for me.

@skirpichev skirpichev closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir invalid type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants