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 1 commit into from Jan 8, 2020


Copy link

@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' TypeError

Copy link

@davidism davidism commented Dec 14, 2019

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

Copy link
Contributor Author

@nvllsvm nvllsvm commented Dec 14, 2019

@nvllsvm nvllsvm force-pushed the fix_exc_pickle branch 2 times, most recently from d964b6d to 33851d9 Compare Dec 16, 2019
Copy link
Contributor Author

@nvllsvm 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
10 checks passed
@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.
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants