Repository navigation
Expose the current JSON Pointer in Decoder callbacks - #260
Open
Aschenbath wants to merge 1 commit into
Open
Aschenbath wants to merge 1 commit into
Aschenbath wants to merge 1 commit into
Conversation
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.
Decoder callbacks currently cannot identify the object key or array position they are processing. Add a read-only
Decoder.pointerproperty following the JSON Pointer approach suggested in #134. For example,string()sees/items/0/namewhile processing the first item's name; the document root is"", and the property isNoneoutside callbacks.Paths use RFC 6901 escaping and describe the input structure before callback replacements. They are constructed on demand from the existing parser context stack. Callback scopes are local to the calling thread and restore the enclosing scope after recursive calls, including failures. Tests cover all four callbacks, nested arrays/objects, duplicate and empty keys, Unicode and NUL keys, text/binary input and small stream chunks, recursive failures, concurrent use of one decoder, and the read-only contract.
The issue's proposed use of a discarding custom mapping also exposed an existing container lifetime bug:
Handle()can release a newly created container before the parser takes its own reference. Retain the context reference before handing the value to its parent. A separate regression covers discarded nested objects/arrays and their eventual release; a minimal reproducer without the new property exits with SIGSEGV against a separately compiled baseline and succeeds with the patch.Validation on Linux CPython 3.12.12 with GCC 15.2 and the native extension rebuilt:
_staticwarning remains.mypy.stubtestand a Unicode streaming consumer that checks the loaded extension's location.git diff --checkpasses.A limited five-round alternating benchmark measured patched/baseline median ratios of 1.005 for nested
loads, 1.010 for a plain Decoder, and 1.043 for a Decoder withstring/end_objectcallbacks that do not read the new property. Flat numeric-array loads measured 0.927; this is not a speedup claim. Debug/free-threaded builds, sanitizers, other Python versions/platforms, and hosted CI have not been verified locally.AI assistance was used for investigation, implementation, tests, and this description. A separate Codex agent reviewed all six changed files and independently checked 300 random documents against an RFC 6901 event oracle, every callback's recursive success/failure restoration, different-decoder nesting, shared-decoder threading, and discarded-container lifetime. No blocking issue was found. This is agent review; no human review is claimed.
Closes #134.