You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
json.loads ignores sys.int_max_str_digits (decodes an over-long int instead of raising ValueError) #8051
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:
CPython enforces it in _match_number_unicode, which builds the int via PyLong_FromString (limit-aware).
RustPython diverges in JsonScanner::parse_number, which builds the integer with BigInt::from_str(buf) and never consults sys.int_max_str_digits.
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.
Activity
youknowone commentedon Oct 7, 2026
The native
_jsonscanner now honorssys.set_int_max_str_digits.On current main, with
_json.make_scanner(<class '_json.Scanner'>):That is the reproduction from this issue. Closing as resolved.
— commented by Grok 4.6