Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pickle/copy support for the missing singleton #2029

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

mattclay
Copy link
Contributor

@mattclay mattclay commented Oct 1, 2024

Fix pickle/copy support for the missing singleton:

  • Fix pickle support for the missing singleton.
  • Add unit test for pickling the missing singleton.
  • Add unit test for copying the missing singleton.

Fixes #2027

@mattclay
Copy link
Contributor Author

mattclay commented Oct 1, 2024

Returning "missing" from __reduce__ is a documented solution for singleton types:

If a string is returned, the string should be interpreted as the name of a global variable. It should be the object’s local name relative to its module; the pickle module searches the module namespace to determine the object’s module. This behaviour is typically useful for singletons.

src/jinja2/utils.py Outdated Show resolved Hide resolved
@davidism davidism added this to the 3.1.5 milestone Dec 18, 2024
@davidism davidism changed the base branch from main to stable December 19, 2024 16:19
@davidism davidism force-pushed the fix-undefined-pickle-copy branch from d3dd9f2 to 7232b82 Compare December 19, 2024 16:19
@davidism davidism merged commit 1dc04bc into pallets:stable Dec 19, 2024
12 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot pickle jinja2.utils.missing
3 participants