-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
THRIFT-5715 Python flag to generate mutable exceptions
In Python 3.11 exceptions generated by the compiler can't be used with a context manager because they are immutable. As of Python 3.11 `contextlib.contextmanager` sets `exc.__stacktrace__` in the event that the code in the context manager errors. As of Thrift v0.18.1 exceptions are generated as immutable by default. See [PR#1835](#1835) for more information about why exceptions were made immutable by default. This change adds a compiler flag, `py:immutible_exc` that generates all exceptions as mutable so they can be used with a context manager. When the flag is used with the `python.immutable = "true"` annotation, the exception is treated as immutable. I tested this change by generating the tutorial and comparing the outputs with and without the new flag. I also copied [tutorial.thrift](tutorial/tutorial.thrift) and added the `python.immutable` annotation to ensure that the annotation always overrides the flag. Where do I go to update documentation?
- Loading branch information
1 parent
dd53b94
commit 402f505
Showing
1 changed file
with
34 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters