MCPcopy Index your code
hub / github.com/RustPython/RustPython / _ContextManager

Class _ContextManager

Lib/_pydecimal.py:3832–3845  ·  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

3830##### Context class #######################################################
3831
3832class _ContextManager(object):
3833 """Context manager class to support localcontext().
3834
3835 Sets a copy of the supplied context in __enter__() and restores
3836 the previous decimal context in __exit__()
3837 """
3838 def __init__(self, new_context):
3839 self.new_context = new_context.copy()
3840 def __enter__(self):
3841 self.saved_context = getcontext()
3842 setcontext(self.new_context)
3843 return self.new_context
3844 def __exit__(self, t, v, tb):
3845 setcontext(self.saved_context)
3846
3847class Context(object):
3848 """Contains the context for a Decimal instance.

Callers 1

localcontextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected