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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mattclay
Copy link

@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 and others added 2 commits October 1, 2024 15:25
* Fix pickle support for the `missing` singleton.
* Add unit test for pickling the `missing` singleton.
* Add unit test for copying the `missing` singleton.
@mattclay
Copy link
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
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.

Cannot pickle jinja2.utils.missing
3 participants