Skip to content

Preserve HeaderTuple fields when copying or pickling - #301

Open
AryanRG wants to merge 1 commit into
python-hyper:masterfrom
AryanRG:fix/header-tuple-pickling
Open

AryanRG wants to merge 1 commit into
python-hyper:masterfrom
AryanRG:fix/header-tuple-pickling

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026

Copy link
Copy Markdown

Summary

Preserve the two fields of HeaderTuple and NeverIndexedHeaderTuple when they are copied or serialized. The inherited tuple reconstruction hook passes the entire pair as one argument to these classes' variadic constructor; copying or pickling therefore nests the pair, and re-encoding a copied decoded header can raise IndexError.

__getnewargs__() now supplies the two fields as separate constructor arguments. The change also adds copy, deepcopy, pickle-protocol, and decode–copy–encode regressions, plus a changelog entry.

Validation

  • The new regression selection has 14 failures and 4 passing controls on the base; all 18 pass with this patch.
  • Full local suite: 520 passed each on Python 3.11, 3.13, and 3.14, with 100% reported statement/branch coverage.
  • Ruff, strict mypy, and whitespace checks pass. Other platforms, hosted CI, packaging, and documentation builds remain unverified.
  • Existing malformed pickles are not repaired.

AI assistance was used to prepare the implementation, tests, and this description.

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.

1 participant