mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #15783: Except for the number methods, the C version of decimal now
supports all None default values present in decimal.py. These values were largely undocumented.
This commit is contained in:
parent
618c2e13ca
commit
040e311826
8 changed files with 625 additions and 233 deletions
|
@ -2596,7 +2596,7 @@ class Decimal(object):
|
|||
ans = ans._fix(context)
|
||||
return ans
|
||||
|
||||
def same_quantum(self, other):
|
||||
def same_quantum(self, other, context=None):
|
||||
"""Return True if self and other have the same exponent; otherwise
|
||||
return False.
|
||||
|
||||
|
@ -2914,7 +2914,7 @@ class Decimal(object):
|
|||
except TypeError:
|
||||
return 0
|
||||
|
||||
def canonical(self, context=None):
|
||||
def canonical(self):
|
||||
"""Returns the same Decimal object.
|
||||
|
||||
As we do not have different encodings for the same number, the
|
||||
|
@ -2934,7 +2934,7 @@ class Decimal(object):
|
|||
return ans
|
||||
return self.compare(other, context=context)
|
||||
|
||||
def compare_total(self, other):
|
||||
def compare_total(self, other, context=None):
|
||||
"""Compares self to other using the abstract representations.
|
||||
|
||||
This is not like the standard compare, which use their numerical
|
||||
|
@ -3007,7 +3007,7 @@ class Decimal(object):
|
|||
return _Zero
|
||||
|
||||
|
||||
def compare_total_mag(self, other):
|
||||
def compare_total_mag(self, other, context=None):
|
||||
"""Compares self to other using abstract repr., ignoring sign.
|
||||
|
||||
Like compare_total, but with operand's sign ignored and assumed to be 0.
|
||||
|
@ -3029,7 +3029,7 @@ class Decimal(object):
|
|||
else:
|
||||
return _dec_from_triple(1, self._int, self._exp, self._is_special)
|
||||
|
||||
def copy_sign(self, other):
|
||||
def copy_sign(self, other, context=None):
|
||||
"""Returns self with the sign of other."""
|
||||
other = _convert_other(other, raiseit=True)
|
||||
return _dec_from_triple(other._sign, self._int,
|
||||
|
@ -4182,7 +4182,7 @@ class Context(object):
|
|||
"""
|
||||
if not isinstance(a, Decimal):
|
||||
raise TypeError("canonical requires a Decimal as an argument.")
|
||||
return a.canonical(context=self)
|
||||
return a.canonical()
|
||||
|
||||
def compare(self, a, b):
|
||||
"""Compares values numerically.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue