Mercurial > cpython-lru_cache-weakref
diff Lib/decimal.py @ 46111:2bcbd3882eee
Merged revisions 61892,61900 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61892 | mark.dickinson | 2008-03-25 15:33:23 +0100 (Tue, 25 Mar 2008) | 3 lines
Issue #2478: Decimal(sqrt(0)) failed when the decimal context
was not explicitly supplied.
........
r61900 | georg.brandl | 2008-03-25 18:36:43 +0100 (Tue, 25 Mar 2008) | 2 lines
Add Benjamin.
........
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Wed, 26 Mar 2008 12:55:56 +0000 |
| parents | 058fbfb985ae |
| children | ea30f03b24f4 |
line wrap: on
line diff
--- a/Lib/decimal.py Wed Mar 26 09:00:12 2008 +0000 +++ b/Lib/decimal.py Wed Mar 26 12:55:56 2008 +0000 @@ -2454,6 +2454,9 @@ def sqrt(self, context=None): """Return the square root of self.""" + if context is None: + context = getcontext() + if self._is_special: ans = self._check_nans(context=context) if ans: @@ -2467,9 +2470,6 @@ ans = _dec_from_triple(self._sign, '0', self._exp // 2) return ans._fix(context) - if context is None: - context = getcontext() - if self._sign == 1: return context._raise_error(InvalidOperation, 'sqrt(-x), x > 0')
