[Python-checkins] r62666 - in python/trunk: Doc/library/decimal.rst Lib/decimal.py

mark.dickinson python-checkins at python.org
Sat May 3 20:23:14 CEST 2008


Author: mark.dickinson
Date: Sat May  3 20:23:14 2008
New Revision: 62666

Log:
Backport Raymond's changes in r60508 to Python 2.6.
'Context flags get set, not incremented'


Modified:
   python/trunk/Doc/library/decimal.rst
   python/trunk/Lib/decimal.py

Modified: python/trunk/Doc/library/decimal.rst
==============================================================================
--- python/trunk/Doc/library/decimal.rst	(original)
+++ python/trunk/Doc/library/decimal.rst	Sat May  3 20:23:14 2008
@@ -100,7 +100,7 @@
 :const:`Overflow`, and :const:`Underflow`.
 
 For each signal there is a flag and a trap enabler.  When a signal is
-encountered, its flag is incremented from zero and, then, if the trap enabler is
+encountered, its flag is set to one, then, if the trap enabler is
 set to one, an exception is raised.  Flags are sticky, so the user needs to
 reset them before monitoring a calculation.
 
@@ -1121,7 +1121,7 @@
 Signals represent conditions that arise during computation. Each corresponds to
 one context flag and one context trap enabler.
 
-The context flag is incremented whenever the condition is encountered. After the
+The context flag is set whenever the condition is encountered. After the
 computation, flags may be checked for informational purposes (for instance, to
 determine whether a computation was exact). After checking the flags, be sure to
 clear all flags before starting the next computation.

Modified: python/trunk/Lib/decimal.py
==============================================================================
--- python/trunk/Lib/decimal.py	(original)
+++ python/trunk/Lib/decimal.py	Sat May  3 20:23:14 2008
@@ -3593,7 +3593,7 @@
     traps - If traps[exception] = 1, then the exception is
                     raised when it is caused.  Otherwise, a value is
                     substituted in.
-    flags  - When an exception is caused, flags[exception] is incremented.
+    flags  - When an exception is caused, flags[exception] is set.
              (Whether or not the trap_enabler is set)
              Should be reset by user of Decimal instance.
     Emin -   Minimum exponent
@@ -3661,16 +3661,16 @@
         """Handles an error
 
         If the flag is in _ignored_flags, returns the default response.
-        Otherwise, it increments the flag, then, if the corresponding
+        Otherwise, it sets the flag, then, if the corresponding
         trap_enabler is set, it reaises the exception.  Otherwise, it returns
-        the default value after incrementing the flag.
+        the default value after setting the flag.
         """
         error = _condition_map.get(condition, condition)
         if error in self._ignored_flags:
             # Don't touch the flag
             return error().handle(self, *args)
 
-        self.flags[error] += 1
+        self.flags[error] = 1
         if not self.traps[error]:
             # The errors define how to handle themselves.
             return condition().handle(self, *args)


More information about the Python-checkins mailing list