Skip to content

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

Closed as not planned
@hyperkai

Description

@hyperkai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirinvalidtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions