summaryrefslogtreecommitdiffstats
path: root/Lib/decimal.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-07-04 01:55:39 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-07-04 01:55:39 (GMT)
commitb1b605ef546c45eac3c53db369ea6e881f05dc8b (patch)
tree498f27a9d8294674f6b78bd35b8b8a9c6929aa5d /Lib/decimal.py
parentd4be86cb0907cc85861a7c8087698964c403ae2a (diff)
downloadcpython-b1b605ef546c45eac3c53db369ea6e881f05dc8b.zip
cpython-b1b605ef546c45eac3c53db369ea6e881f05dc8b.tar.gz
cpython-b1b605ef546c45eac3c53db369ea6e881f05dc8b.tar.bz2
Fix clear_flags(). Make a readable (not evalable) Context repr.
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r--Lib/decimal.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py
index b8c1322..3eee436 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -2154,10 +2154,18 @@ class Context(object):
self.DefaultLock.release()
del self.self
+ def __repr__(self):
+ """Show the current context in readable form, not in a form for eval()."""
+ s = []
+ s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d' % vars(self))
+ s.append('setflags=%r' % [f.__name__ for f, v in self.flags.items() if v])
+ s.append('settraps=%r' % [t.__name__ for t, v in self.trap_enablers.items() if v])
+ return ', '.join(s) + ')'
+
def clear_flags(self):
"""Reset all flags to zero"""
for flag in self.flags:
- self.flag = 0
+ self.flags[flag] = 0
def copy(self):
"""Returns a copy from self."""