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

Conversation

@nvllsvm
Copy link
Contributor

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

nvllsvm commented Dec 14, 2019

@nvllsvm nvllsvm force-pushed the nvllsvm:fix_exc_pickle branch 2 times, most recently from d964b6d to 33851d9 Dec 16, 2019
@nvllsvm

This comment has been minimized.

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 force-pushed the nvllsvm:fix_exc_pickle branch from 33851d9 to b23a0de Jan 8, 2020
@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
10 checks passed
Tests Build #20200108.1 succeeded
Details
Tests (Job Docs) Job Docs succeeded
Details
Tests (Job PyPy 3 Linux) Job PyPy 3 Linux succeeded
Details
Tests (Job Python 2.7 Linux) Job Python 2.7 Linux succeeded
Details
Tests (Job Python 2.7 Windows) Job Python 2.7 Windows succeeded
Details
Tests (Job Python 3.5 Linux) Job Python 3.5 Linux succeeded
Details
Tests (Job Python 3.6 Linux) Job Python 3.6 Linux succeeded
Details
Tests (Job Python 3.7 Linux) Job Python 3.7 Linux succeeded
Details
Tests (Job Python 3.7 Mac) Job Python 3.7 Mac succeeded
Details
Tests (Job Python 3.7 Windows) Job Python 3.7 Windows succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.