Context manager class to support localcontext(). Sets a copy of the supplied context in __enter__() and restores the previous decimal context in __exit__()
| 3833 | ##### Context class ####################################################### |
| 3834 | |
| 3835 | class _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 | |
| 3850 | class Context(object): |
| 3851 | """Contains the context for a Decimal instance. |
no outgoing calls
no test coverage detected
searching dependent graphs…