Python: Serialize large integers as strings in RPC#6829
Merged
knutwannheden merged 1 commit intomainfrom Feb 26, 2026
Merged
Conversation
…imits Jackson 2.15+ rejects JSON numbers exceeding 1000 digits via StreamReadConstraints.getMaxNumberLength(). Python integers have no size limit, so a literal like paramiko's 4096-bit DH prime (1234 decimal digits) was serialized as a raw JSON number, causing deserialization to fail on the Java side. Convert integers exceeding Java's long range to strings before serialization. The original source representation is preserved in the literal's valueSource field, so printing is unaffected.
fac8559 to
41e1bc8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Convert Python integers exceeding Java's
longrange (±2^63) to strings in_get_primitive_valuebefore JSON serialization, avoiding Jackson'sStreamReadConstraints.getMaxNumberLength()limit (default 1000 digits).Context
Python integers have no size limit. When a literal like
P = 0xFFFF...FFFF(a 1026-char hex / 1234-digit decimal number) is serialized via_get_primitive_value, it was sent as a raw JSON number. Jackson 2.15+ rejects numbers exceeding 1000 digits, causing deserialization failure. The error was then silently dropped by the JSON-RPC layer (fix in moderneinc/jsonrpc#14), causing the caller to hang indefinitely.The literal's
valueSourcefield already carries the original hex string, so printing is unaffected by converting the value to a string.