Skip to content

Fix pickle/copy support for the missing singleton#2029

Merged
davidism merged 1 commit intopallets:stablefrom
mattclay:fix-undefined-pickle-copy
Dec 19, 2024
Merged

Fix pickle/copy support for the missing singleton#2029
davidism merged 1 commit intopallets:stablefrom
mattclay:fix-undefined-pickle-copy

Conversation

@mattclay
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/jinja2/utils.py Outdated
@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
@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