MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _ContextManager

Class _ContextManager

tools/python-3.11.9-amd64/Lib/_pydecimal.py:3868–3881  ·  view source on GitHub ↗

Context manager class to support localcontext(). Sets a copy of the supplied context in __enter__() and restores the previous decimal context in __exit__()

Source from the content-addressed store, hash-verified

3866##### Context class #######################################################
3867
3868class _ContextManager(object):
3869 """Context manager class to support localcontext().
3870
3871 Sets a copy of the supplied context in __enter__() and restores
3872 the previous decimal context in __exit__()
3873 """
3874 def __init__(self, new_context):
3875 self.new_context = new_context.copy()
3876 def __enter__(self):
3877 self.saved_context = getcontext()
3878 setcontext(self.new_context)
3879 return self.new_context
3880 def __exit__(self, t, v, tb):
3881 setcontext(self.saved_context)
3882
3883class Context(object):
3884 """Contains the context for a Decimal instance.

Callers 1

localcontextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected