Author: Amaury Forgeot d'Arc <[email protected]> Branch: decimal-libmpdec Changeset: r73051:b763ba8d4b7e Date: 2014-08-24 23:19 +0200 http://bitbucket.org/pypy/pypy/changeset/b763ba8d4b7e/
Log: Add missing file diff --git a/pypy/module/_decimal/app_context.py b/pypy/module/_decimal/app_context.py new file mode 100644 --- /dev/null +++ b/pypy/module/_decimal/app_context.py @@ -0,0 +1,17 @@ +from _decimal import getcontext, setcontext + +class _ContextManager(object): + """Context manager class to support localcontext().""" + def __init__(self, new_context): + self.new_context = new_context.copy() + def __enter__(self): + self.saved_context = getcontext() + setcontext(self.new_context) + return self.new_context + def __exit__(self, t, v, tb): + setcontext(self.saved_context) + +def localcontext(ctx=None): + if ctx is None: + ctx = getcontext() + return _ContextManager(ctx) _______________________________________________ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
