diff options
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 75a1d5e..a2e7fa4 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -2454,6 +2454,9 @@ class Decimal(_numbers.Real): 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 @@ class Decimal(_numbers.Real): 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') |