Skip to content

Preserve the pure-Python pickler on PyPy - #606

Open
liuyinchu wants to merge 1 commit into
cloudpipe:masterfrom
liuyinchu:fix/pypy-pickler-base-592
Open

liuyinchu wants to merge 1 commit into
cloudpipe:masterfrom
liuyinchu:fix/pypy-pickler-base-592

Conversation

@liuyinchu

Copy link
Copy Markdown

Addresses the import failure reported in #592.

PyPy 7.3.22 changed pickle.Pickler to an accelerated implementation without a
dispatch dictionary. Keep cloudpickle on pickle._Pickler for PyPy, preserving
its previous backend and PyPy-specific function handling. Use the selected base
consistently for inheritance, dispatch copying and backend selection.

Using the accelerated backend instead restores import but introduces additional
failures: its reducer_override recurses on six-item reductions with state
setters, and cloudpickle's PyPy builtin-function fallback is bypassed. A minimal
stdlib-only state-setter reproducer is available with the validation material.

Tests

  • New backend regression passes all protocols 0–5 on CPython 3.12.14 and actual
    PyPy 7.3.16, 7.3.22 and 8.0.0: 48 parameterized cases total
  • Covers importable functions/classes, ordinary and binary data, dynamic classes
    with custom metaclasses, instance/class identity, and accelerated function-hook routing
  • CPython suite excluding notebook tests: 274 passed, 10 skipped, 2 xfailed
  • Legacy PyPy suite: 267 passed, 18 skipped, 2 xfailed
  • Existing builtin-classmethod tests pass on all three PyPy runtimes
  • Repository-pinned pre-commit checks pass

Scope and remaining failures

This restores import and the prior PyPy backend behavior. It does not claim full
modern PyPy support. Function/code serialization still reaches the separate
CodeType mismatch addressed by #566 on PyPy 7.3.22; PyPy 8.0.0 also places the
exceptiontable constructor argument differently from CPython. Those changes are
not included here. A bounded modern-suite run on each interpreter stops at five
CodeType failures (39 passed, 2 skipped before stopping).

Four CPython notebook tests fail to start Jupyter kernels because the validation
sandbox denies ZMQ network operations. They fail identically on baseline.

AI disclosure

This patch, tests and draft were prepared with OpenAI coding assistance and
reviewed independently by another AI reviewer. The recorded tests were run on
real CPython and PyPy interpreters. No human maintainer review or upstream CI
result is claimed.

@liuyinchu
liuyinchu marked this pull request as ready for review October 3, 2026 17:17

This branch has not been deployed

No deployments
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