summaryrefslogtreecommitdiffstats
path: root/Lib/decimal.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-03-25 14:33:23 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2008-03-25 14:33:23 (GMT)
commit3b24ccbe7e2b43c4373e4b1e988df55978b819e7 (patch)
treec52e728abc2a9a08812e9222d6b3d09e63f6bcea /Lib/decimal.py
parentf8f1fbd53c3a2b7fdda863f11242a976ec490e8f (diff)
downloadcpython-3b24ccbe7e2b43c4373e4b1e988df55978b819e7.zip
cpython-3b24ccbe7e2b43c4373e4b1e988df55978b819e7.tar.gz
cpython-3b24ccbe7e2b43c4373e4b1e988df55978b819e7.tar.bz2
Issue #2478: Decimal(sqrt(0)) failed when the decimal context
was not explicitly supplied.
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r--Lib/decimal.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 5d25012..b775bee 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -2453,6 +2453,9 @@ class Decimal(object):
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:
@@ -2466,9 +2469,6 @@ class Decimal(object):
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')