GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Expose the current JSON Pointer in Decoder callbacks by Aschenbath · Pull Request #260 · python-rapidjson/python-rapidjson

Conversation

@Aschenbath

@Aschenbath Aschenbath commented Nov 7, 2026

Copy link
Copy Markdown

Decoder callbacks currently cannot identify the object key or array position they are processing. Add a read-only Decoder.pointer property following the JSON Pointer approach suggested in #134. For example, string() sees /items/0/name while processing the first item's name; the document root is "", and the property is None outside 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:

  • All 29 pointer cases fail on the unchanged baseline; the final full suite passes 1,478 tests, with 31 skips and 2 expected failures.
  • All 276 Sphinx doctests pass. The repository's pinned Sphinx 9.2.0 was unavailable from the package index, so these ran with 9.1.1; the other test requirements use their specified versions. The existing missing _static warning remains.
  • A wheel installed outside the checkout passes mypy.stubtest and a Unicode streaming consumer that checks the loaded extension's location.
  • git diff --check passes.

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 with string/end_object callbacks 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Aschenbath
Expose the current JSON Pointer in Decoder callbacks
1679249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Any way to know the current object being parsed?

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Aschenbath
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.