MCPcopy Index your code
hub / github.com/python/cpython / _ContextManager

Class _ContextManager

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

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

Callers 1

localcontextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…