Skip to content

Deprecate the 2.x Lexicon translation: a 2.x pickle load warns (#754) - #1002

Merged
derek73 merged 2 commits into
masterfrom
feat/deprecate-2x-lexicon-translation
Nov 2, 2026
Merged

derek73 merged 2 commits into
masterfrom
feat/deprecate-2x-lexicon-translation

Conversation

@derek73

@derek73 derek73 commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Part of #754. Makes the decided lifetime of the 2.x translation real: it is migration scaffolding, kept in 3.0 deprecated and deleted in 3.1.

What changes

  • A 2.x Lexicon pickle load warns. Lexicon.__setstate__ emits a DeprecationWarning after a 2.x state loads successfully. It fires once for each Lexicon loaded, so a Parser or locale pack holding one warns once, and a refused state raises without a warning. The message says the pickle was written by nameparser 2.x, that 3.1 will refuse it, and that the loaded object should be re-pickled under 3.0 (pickle.dumps(obj)).
  • The warning points at the caller's line. _warn_at_caller gains a category parameter. pickle.loads is C and adds no Python frame, so the helper's walk reaches the caller's own pickle.loads line. A test pins w.filename == __file__.
  • The old-spelling refusals are unchanged. They already raise with their per-word fix, so no warning is added.
  • The _lexicon.py diff stays at the warning site. The translation code itself is untouched; a parallel simplify pass is working elsewhere in that file.

Tests

  • The existing 2.x pickle tests now assert the warning. _loaded records it and asserts exactly one DeprecationWarning with the message.
  • New: the message is pinned in full, with two warnings for the 2.8.0 fixture (it holds two distinct Lexicons), each attributed to the test file.
  • New: the remedy runs. Load, re-pickle, load again: no warning, and the objects are equal.
  • New: a 3.0 pickle (parsers_4ib.pickle, and a fresh one) loads with no warning.

Docs

  • decisions/vocabulary-model: a dated entry recording the lifetime, what 3.1 does instead, and why that is a minor-release change. In 3.1, an old spelling gets a short fixed TypeError pointing at docs/migrate.rst's table of kinds, and a 2.x pickle is refused with "re-pickle under 3.0". The calls already fail in 3.0, and pickle breaks ship in minors with a release-log bullet.
  • docs/migrate.rst: a short note on the warning, the re-pickle remedy and the 3.1 change to the errors.
  • Release log: one bullet under Unreleased.
  • AGENTS.md Pickling bullet: notes the warning, and asks that nothing new be built on the translation.

Gates

  • uv run pytest (34,737 passed) and --python 3.15: pass.
  • -n0 -m serial: 42 passed on a quiet machine. A first run under load from parallel sessions failed 5 timing tests.
  • mypy, ruff: pass.
  • Sphinx doctest build (0 failures) and README.rst: pass.
  • snapshot.jsonl: byte-identical. No parse moves.

The 3.1 deletion is #1003; the decisions entry and the release bullet point at it.

🤖 Generated with Claude Code

@derek73 derek73 added this to the 3.0 milestone Nov 2, 2026
@derek73 derek73 added docs Documentation fixes and updates breaking-change Backwards-incompatible API change labels Nov 2, 2026
@derek73 derek73 self-assigned this Nov 2, 2026
derek73 and others added 2 commits November 2, 2026 14:59
The translation of 2.x set spellings and pickles into readings is
migration scaffolding: it stays in 3.0 and is deleted in 3.1. A
Lexicon pickled by 2.x (and a Parser or locale pack holding one) now
loads with a DeprecationWarning, once per Lexicon, attributed to the
caller's pickle.loads line, naming the re-pickle remedy. The old
spellings already raise, so their per-word fix is unchanged.

Records the lifetime and what 3.1 does instead in
decisions/vocabulary-model; notes it in docs/migrate.rst, the release
log and AGENTS.md's Pickling bullet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73
derek73 force-pushed the feat/deprecate-2x-lexicon-translation branch from 062a0ef to 1e56caa Compare November 2, 2026 23:00
@derek73
derek73 merged commit b2b7594 into master Nov 2, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Backwards-incompatible API change docs Documentation fixes and updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant