pep-550: Drop context isolation for now (#333)
This commit is contained in:
parent
3c5f66da61
commit
cc0823979c
21
pep-0550.rst
21
pep-0550.rst
|
@ -968,27 +968,6 @@ trampoline, making it impossible to intercept their ``yield`` points
|
||||||
outside of the Python interpreter.
|
outside of the Python interpreter.
|
||||||
|
|
||||||
|
|
||||||
Is it possible to write a context manager to isolate EC changes?
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
Yes!
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
|
||||||
def isolated_context():
|
|
||||||
old_ctx = sys.get_execution_context()
|
|
||||||
try:
|
|
||||||
yield
|
|
||||||
finally:
|
|
||||||
sys.set_execution_context(old_ctx)
|
|
||||||
|
|
||||||
|
|
||||||
with isolated_context():
|
|
||||||
# Any Execution Context changes will not be visible
|
|
||||||
# outside of this block.
|
|
||||||
|
|
||||||
|
|
||||||
Reference Implementation
|
Reference Implementation
|
||||||
========================
|
========================
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue