-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Documentation
The documentation here: https://docs.python.org/3/library/stdtypes.html#affected-apis
says that int.from_bytes is not affected by the integer string conversion limit.
The limitations do not apply to functions with a linear algorithm:
- int(string, base) with base 2, 4, 8, 16, or 32.
- int.from_bytes() and int.to_bytes().
However, it seems that it is. I've reproduced this on both 3.10 and 3.12:
Python 3.10.13 (main, Dec 12 2023, 22:43:26) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> int.from_bytes(b'\x80'+b'\0'*100000, byteorder='big')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Exceeds the limit (4300) for integer string conversion; use sys.set_int_max_str_digits() to increase the limitPython 3.12.2 (main, Apr 21 2024, 00:52:02) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> int.from_bytes(b'\x80'+b'\0'*100000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limittomasr8
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir