diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-09-08 19:23:44 +0000 |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-09-08 19:23:44 +0000 |
commit | 77dfccbb3b3645372d9672357ea5904c2cad8470 (patch) | |
tree | 2ee267cfc50f678114ebcd904df1e21caa65d6d0 /Lib/decimal.py | |
parent | 4d4adace513200ab3d71617d575e3a22874cb410 (diff) | |
download | cpython-77dfccbb3b3645372d9672357ea5904c2cad8470.tar.gz |
Merged revisions 74709 via svnmerge from
svn+ssh://pythondev@www.python.org/python/branches/py3k
................
r74709 | mark.dickinson | 2009-09-07 19:08:12 +0100 (Mon, 07 Sep 2009) | 9 lines
Merged revisions 74708 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r74708 | mark.dickinson | 2009-09-07 19:04:58 +0100 (Mon, 07 Sep 2009) | 2 lines
#Issue 6795: Fix infinite recursion in long(Decimal('nan')); change int(Decimal('nan')) to raise ValueError instead of either returning NaN or raising InvalidContext.
........
................
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index e3af3f0812..e3fa8cb84f 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -1553,10 +1553,9 @@ class Decimal(object): """Converts self to an int, truncating if necessary.""" if self._is_special: if self._isnan(): - context = getcontext() - return context._raise_error(InvalidContext) + raise ValueError("Cannot convert NaN to integer") elif self._isinfinity(): - raise OverflowError("Cannot convert infinity to int") + raise OverflowError("Cannot convert infinity to integer") s = (-1)**self._sign if self._exp >= 0: return s*int(self._int)*10**self._exp |