-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cannot pickle jinja2.utils.missing
#2027
Comments
Looks like a few folks have started looking at pickling all of a sudden. Note that it is not a goal of Jinja to have it's internal structure be pickleable. While I'm willing to consider it, it's not a priority. It might help if I understood why you were trying to do this. |
Yeah, it probably would've made more sense if the repro on this one was in the context of #2025. In our case, it's not about pickling per se (agreed, generally silly for Jinja to support), but that |
(we also have a local monkeypatch workaround and a PR on the way for this one) |
Right, but is there a reason to pass undefined around? It's probably coming from your use of native environment, but what's the purpose of passing it on? Maybe it would make more sense to discard undefined items (or items with undefined members) or replace them with none. Then you're storing plain Python data rather than internal Jinja state. |
We eventually do, but only at the very end of the overall templating pipeline before we stash the result. Ansible has always had a gnarly layer around Jinja that adds recursive/chained/indirect templating, and we've been working in a private branch to improve performance and tighten up our interactions with Jinja. Part of that increases our reliance on several custom |
The
jinja2.utils.missing
singleton instance cannot be pickled since pickle cannot findMissingType
due to thejinja2.utils.MissingType
attribute not existing:Running the above code results in the following error:
Attempting to pickle (and then restore) the
jinja2.utils.missing
singleton instance should succeed. Supporting this would allow pickling ofjinja2.runtime.Undefined
instances which do not setobj
, once #2025 is also resolved.Environment:
The text was updated successfully, but these errors were encountered: