Skip to content

int() accepts strings with underscores in free-threading build (should raise ValueError) #139222

@DengYuncheng27

Description

@DengYuncheng27

Bug report

Bug description:

In the experimental free-threading build of python-freethreaded.3.13.1 , the int() function unexpectedly accepts strings containing underscores (e.g., '1806_1') and silently converts them to integers by ignoring the underscores — returning 18061.
print(int('1806_1')) # 18061

This behavior violates the documented and long-standing specification of int(), which should raise a ValueError for such input.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions