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 TemplateSyntaxError pickling #1117

Merged
merged 1 commit into from
Jan 8, 2020
Merged

Fix TemplateSyntaxError pickling #1117

merged 1 commit into from
Jan 8, 2020

Conversation

nvllsvm
Copy link
Contributor

@nvllsvm nvllsvm commented Dec 13, 2019

Implement __reduce__ to fix pickling of TemplateSyntaxError

New test output without the fix (Python 3.8):

________________________________________ TestDebug.test_pickleable_syntax_error _________________________________________

self = <test_debug.TestDebug object at 0x109740490>, fs_env = <jinja2.environment.Environment object at 0x1097400a0>

    def test_pickleable_syntax_error(self, fs_env):
        exc = TemplateSyntaxError('wtf', 42)
        pickled_exc = pickle.dumps(exc)
>       unpickled_exc = pickle.loads(pickled_exc)
E       TypeError: __init__() missing 1 required positional argument: 'lineno'

test_debug.py:78: TypeError

@davidism
Copy link
Member

davidism commented Dec 14, 2019

Interesting. Seems like it would be better to address why lineno isn't getting pickled/unpickled.

@nvllsvm
Copy link
Contributor Author

nvllsvm commented Dec 14, 2019

@nvllsvm
Copy link
Contributor Author

nvllsvm commented Dec 16, 2019

@davidism Changed the fix to only override __reduce__. No other changes to the exception.

@davidism davidism added this to the 2.11.0 milestone Jan 8, 2020
@davidism davidism merged commit 8342180 into pallets:master Jan 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
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.

2 participants