Feature
json.loads should honor the interpreter's integer string-conversion limit (sys.set_int_max_str_digits, PEP 651). RustPython's native _json scanner (the Rust-implemented accelerated module, RustPython's analog of CPython's C _json) decodes an over-long integer literal instead of raising ValueError. The pure-Python decoder already honors the limit (its int conversion goes through int(str)); only the native _json scanner diverges.
Surfaced by running CPython's own stdlib test suite under RustPython — test_json.test_decode::TestCDecode.test_limit_int fails. The minimal standalone reproduction:
Reproduction
import sys, json
sys.set_int_max_str_digits(5000)
json.loads('1' * 5001)
CPython 3.14:
ValueError: Exceeds the limit (5000 digits) for integer string conversion: value has 5001 digits
RustPython:
(returns the 5001-digit integer — no error)
Python Documentation or reference to CPython source code
Suggested fix
Route the integer construction through rustpython_common::int::bytes_to_int with the live vm.state.int_max_str_digits (the same path the int() builtin uses), so the limit is read per-call and sys.set_int_max_str_digits / adjust_int_max_str_digits take effect. Float parsing is unaffected. This also unblocks test_json.test_decode::TestCDecode.test_limit_int.
Investigated and drafted with AI assistance (Claude Code), reviewed by a human before filing, per RustPython's AI policy.
Feature
json.loadsshould honor the interpreter's integer string-conversion limit (sys.set_int_max_str_digits, PEP 651). RustPython's native_jsonscanner (the Rust-implemented accelerated module, RustPython's analog of CPython's C_json) decodes an over-long integer literal instead of raisingValueError. The pure-Python decoder already honors the limit (its int conversion goes throughint(str)); only the native_jsonscanner diverges.Surfaced by running CPython's own stdlib test suite under RustPython —
test_json.test_decode::TestCDecode.test_limit_intfails. The minimal standalone reproduction:Reproduction
CPython 3.14:
RustPython:
Python Documentation or reference to CPython source code
sys.set_int_max_str_digits(PEP 651)._match_number_unicode, which builds the int viaPyLong_FromString(limit-aware).JsonScanner::parse_number, which builds the integer withBigInt::from_str(buf)and never consultssys.int_max_str_digits.Suggested fix
Route the integer construction through
rustpython_common::int::bytes_to_intwith the livevm.state.int_max_str_digits(the same path theint()builtin uses), so the limit is read per-call andsys.set_int_max_str_digits/adjust_int_max_str_digitstake effect. Float parsing is unaffected. This also unblockstest_json.test_decode::TestCDecode.test_limit_int.Investigated and drafted with AI assistance (Claude Code), reviewed by a human before filing, per RustPython's AI policy.