summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/decimal.py20
-rw-r--r--Lib/test/test_decimal.py4
2 files changed, 6 insertions, 18 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 9f77b24..d9c3f10 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -114,10 +114,8 @@ __all__ = [
'DefaultContext', 'BasicContext', 'ExtendedContext',
# Exceptions
- 'DecimalException', 'Clamped', 'InvalidOperation', 'ConversionSyntax',
- 'DivisionByZero', 'DivisionImpossible', 'DivisionUndefined',
- 'Inexact', 'InvalidContext', 'Rounded', 'Subnormal', 'Overflow',
- 'Underflow',
+ 'DecimalException', 'Clamped', 'InvalidOperation', 'DivisionByZero',
+ 'Inexact', 'Rounded', 'Subnormal', 'Overflow', 'Underflow',
# Constants for use in setting up contexts
'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING',
@@ -211,12 +209,6 @@ class InvalidOperation(DecimalException):
return Decimal( (args[1]._sign, args[1]._int, 'n') )
return NaN
-# XXX Is there a logic error in subclassing InvalidOperation?
-# Setting the InvalidOperation trap to zero does not preclude ConversionSyntax.
-# Also, incrementing Conversion syntax flag will not increment InvalidOperation.
-# Both of these issues interfere with cross-language portability because
-# code following the spec would not know about the Python subclasses.
-
class ConversionSyntax(InvalidOperation):
"""Trying to convert badly formed string.
@@ -1032,7 +1024,7 @@ class Decimal(object):
if ans:
return ans
- resultsign = operator.xor(self._sign, other._sign)
+ resultsign = self._sign ^ other._sign
if self._isinfinity():
if not other:
return context._raise_error(InvalidOperation, '(+-)INF * 0')
@@ -1126,7 +1118,7 @@ class Decimal(object):
else:
return ans
- sign = operator.xor(self._sign, other._sign)
+ sign = self._sign ^ other._sign
if not self and not other:
if divmod:
return context._raise_error(DivisionUndefined, '0 / 0', 1)
@@ -2117,8 +2109,6 @@ class Context(object):
_clamp - If 1, change exponents if too high (Default 0)
"""
- DefaultLock = threading.Lock()
-
def __init__(self, prec=None, rounding=None,
trap_enablers=None, flags=None,
_rounding_decision=None,
@@ -2127,13 +2117,11 @@ class Context(object):
_ignored_flags=[]):
if flags is None:
flags = dict.fromkeys(Signals, 0)
- self.DefaultLock.acquire()
for name, val in locals().items():
if val is None:
setattr(self, name, copy.copy(getattr(DefaultContext, name)))
else:
setattr(self, name, val)
- self.DefaultLock.release()
del self.self
def __repr__(self):
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index e6d9389..dc202f3 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -134,7 +134,7 @@ class DecimalTest(unittest.TestCase):
#print line
try:
t = self.eval_line(line)
- except ConversionSyntax:
+ except InvalidOperation:
print 'Error in test cases:'
print line
continue
@@ -189,7 +189,7 @@ class DecimalTest(unittest.TestCase):
ans = L[0]
exceptions = L[1:]
except (TypeError, AttributeError, IndexError):
- raise ConversionSyntax
+ raise InvalidOperation
def FixQuotes(val):
val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote')
val = val.replace("'", '').replace('"', '')