Skip to content

Add Python marshal operations - #2719

Open
cnotin wants to merge 1 commit into
gchq:masterfrom
cnotin:agent/python-marshal-support
Open

Add Python marshal operations#2719
cnotin wants to merge 1 commit into
gchq:masterfrom
cnotin:agent/python-marshal-support

Conversation

@cnotin

@cnotin cnotin commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description
Adds client-side Python marshal encode/decode operations for JSON-compatible CPython format 4 values. Byte strings and integers beyond JavaScript's safe range use explicit tagged JSON representations.

The issue suggested the py-marshal npm package. It was deliberately not adopted: its last release was in 2020, its reader lacks several values needed here (including arbitrary-size integers, sets, Unicode/ASCII marshal string variants, and modern reference flags), and its Node Buffer-oriented implementation is unsuitable as a dependable browser-side codec. The new dependency-free codec covers the documented JSON-compatible scope while keeping the operation client-side. It intentionally does not support version-specific Python code objects or other Python-only values that cannot be represented faithfully as JSON.

Existing Issue
Closes #1041.

Screenshots

  • from marshal
image
  • to marshal
image

AI disclosure
This change was created with OpenAI Codex. The implementation, dependency assessment, and tests were generated with its assistance and then validated with CPython 3.14.4 and the full CyberChef test suite.

Test Coverage
Added CPython-generated format 4 fixtures covering null, booleans, integers, floats, strings, byte strings, lists, tuples, sets, and string-keyed dictionaries, plus references and arbitrary-size integer round trips. The fixture-generation command and CPython encoder-fixture assertion are documented in the test file.

Validated with Node.js 24.19.0: 272 Node API tests and 2,285 operation tests passed.

@cnotin
cnotin force-pushed the agent/python-marshal-support branch 2 times, most recently from af0ea8a to 7cf59c8 Compare August 7, 2026 22:55
@cnotin
cnotin force-pushed the agent/python-marshal-support branch from 7cf59c8 to 95313d7 Compare August 7, 2026 23:11
@cnotin
cnotin marked this pull request as ready for review August 7, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Python marshal support

1 participant