Skip to content

THRIFT-6476: Write NaN and Infinity as JSON strings in Python - #4175

Open
aisk wants to merge 1 commit into
apache:masterfrom
aisk:THRIFT-6476
Open

aisk wants to merge 1 commit into
apache:masterfrom
aisk:THRIFT-6476

Conversation

@aisk

@aisk aisk commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Non-finite doubles are now written as the quoted strings "NaN", "Infinity" and "-Infinity" instead of bare nan/inf, which isn't valid JSON.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@aisk
aisk requested a review from mhlakhani as a code owner November 13, 2026 16:26
@mergeable mergeable Bot added the python label Nov 13, 2026

@slachiewicz slachiewicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct: writeJSONDouble now emits "NaN", "Infinity" and "-Infinity" via writeJSONString for non-finite values and leaves writeJSONNumber untouched for finite ones, so existing output is byte-identical. Both TJSONProtocol and TSimpleJSONProtocol are covered, map keys work, and the reader already accepts the quoted tokens, so this closes a genuine write-side hole.

Non-blocking: the new test only covers list elements. The JIRA also calls out map keys and struct fields, and TSimpleJSONProtocol.writeDouble is modified but untested — adding those cases would fully lock in the fix. A one-line PR description would also help reviewers.

Drafted with Claude — please verify

@slachiewicz slachiewicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewing the rewritten head 41a0d6a: the new commit adds the test_non_finite_double_map_key and test_simple_json_non_finite_double cases I asked for, and the PR body now carries a one-line explanation. Both tests look correct — the map-key case pins {"NaN":1} and the simple-JSON case pins "NaN". No other changes beyond the test additions.

The earlier APPROVE was on the superseded commit a31715c; re-approving this head.

Drafted with Claude — please verify

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants