Skip to content

Preserve abstract properties when pickling - #630

Open
nithishreddy5771 wants to merge 3 commits into
cloudpipe:masterfrom
nithishreddy5771:fix/preserve-abstract-properties
Open

nithishreddy5771 wants to merge 3 commits into
cloudpipe:masterfrom
nithishreddy5771:fix/preserve-abstract-properties

Conversation

@nithishreddy5771

Copy link
Copy Markdown

Summary

The property reducer is registered for both property and abc.abstractproperty, but always reconstructs a plain property. This loses the legacy descriptor's abstract flag.

After a by-value round trip, the base class retains its saved abstract-method set. However, a new subclass recomputes that set from the now-concrete property and can be instantiated without implementing it, executing the abstract placeholder instead.

Reconstruct the descriptor with type(obj), as the neighboring class/static-method reducer already does. Add isolated regressions across protocols 0-5 for descriptor type, abstractness, documentation, getter/setter/deleter behavior, incomplete subclasses and valid concrete subclasses. Ordinary properties and the modern @property plus @abstractmethod form are controls.

abc.abstractproperty is deprecated but explicitly supported by cloudpickle. This is a small legacy-path correctness fix; the modern form already works.

Validation

  • The 24 new cases give 12 failures and 12 passing controls on original source, then 24 passes with the fix.
  • Python 3.10.12: full baseline 273 passed, 3 skipped, 2 xfailed; fixed 297 passed, 3 skipped, 2 xfailed.
  • Python 3.11.18: full baseline 273 passed, 3 skipped, 2 xfailed; fixed 297 passed, 3 skipped, 2 xfailed.
  • Python 3.13.18: full baseline 265 passed, 11 skipped, 2 xfailed; fixed 289 passed, 11 skipped, 2 xfailed. Both retain the same two existing warnings.
  • A separate fresh-interpreter probe confirms that an incomplete subclass executes the placeholder before the fix and correctly raises TypeError afterward on all six protocols.
  • Black 25.9.0 and Ruff 0.14.3 checks pass for both changed Python files; git diff --check passes.

Checks ran on Linux with compatible dependencies from the development requirements, not a lock file. Other Python versions, PyPy, Windows/macOS and downstream integrations were not tested. No production incident or coverage percentage is claimed.

Implemented and tested by an AI assistant on my behalf. Separate automated validation covered Python 3.10; no human code review is claimed.

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