https://github.com/python/cpython/commit/6bed57a3b659a34c4a7d75e76f4fe840f762bf7f
commit: 6bed57a3b659a34c4a7d75e76f4fe840f762bf7f
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-05-24T15:02:32+03:00
summary:
gh-150285: Fix too long docstrings in the decimal module (GH-150288)
files:
M Lib/_pydecimal.py
M Modules/_decimal/_decimal.c
M Modules/_decimal/clinic/_decimal.c.h
diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py
index ef889ea0cc834c1..8c0afd14d616e85 100644
--- a/Lib/_pydecimal.py
+++ b/Lib/_pydecimal.py
@@ -107,8 +107,8 @@ class DecimalException(ArithmeticError):
anything, though.
handle -- Called when context._raise_error is called and the
- trap_enabler is not set. First argument is self, second is the
- context. More arguments can be given, those being after
+ trap_enabler is not set. First argument is self, second is
+ the context. More arguments can be given, those being after
the explanation in _raise_error (For example,
context._raise_error(NewError, '(-x)!', self._sign) would
call NewError().handle(context, self._sign).)
@@ -225,11 +225,12 @@ class InvalidContext(InvalidOperation):
"""Invalid context. Unknown rounding, for example.
This occurs and signals invalid-operation if an invalid context was
- detected during an operation. This can occur if contexts are not checked
- on creation and either the precision exceeds the capability of the
- underlying concrete representation or an unknown or unsupported rounding
- was specified. These aspects of the context need only be checked when
- the values are required to be used. The result is [0,qNaN].
+ detected during an operation. This can occur if contexts are not
+ checked on creation and either the precision exceeds the capability of
+ the underlying concrete representation or an unknown or unsupported
+ rounding was specified. These aspects of the context need only be
+ checked when the values are required to be used. The result is
+ [0,qNaN].
"""
def handle(self, context, *args):
@@ -322,8 +323,9 @@ class FloatOperation(DecimalException, TypeError):
Decimal.from_float() or context.create_decimal_from_float() do not
set the flag.
- Otherwise (the signal is trapped), only equality comparisons and explicit
- conversions are silent. All other mixed operations raise FloatOperation.
+ Otherwise (the signal is trapped), only equality comparisons and
+ explicit conversions are silent. All other mixed operations raise
+ FloatOperation.
"""
# List of public traps and flags
@@ -2901,8 +2903,8 @@ 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
- value. Note that a total ordering is defined for all possible abstract
- representations.
+ value. Note that a total ordering is defined for all possible
+ abstract representations.
"""
other = _convert_other(other, raiseit=True)
@@ -2973,7 +2975,8 @@ def compare_total(self, other, context=None):
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.
+ Like compare_total, but with operand's sign ignored and assumed to
+ be 0.
"""
other = _convert_other(other, raiseit=True)
@@ -4110,9 +4113,9 @@ def create_decimal_from_float(self, f):
def abs(self, a):
"""Returns the absolute value of the operand.
- If the operand is negative, the result is the same as using the minus
- operation on the operand. Otherwise, the result is the same as using
- the plus operation on the operand.
+ If the operand is negative, the result is the same as using the
+ minus operation on the operand. Otherwise, the result is the same
+ as using the plus operation on the operand.
>>> ExtendedContext.abs(Decimal('2.1'))
Decimal('2.1')
@@ -4168,16 +4171,17 @@ def canonical(self, a):
def compare(self, a, b):
"""Compares values numerically.
- If the signs of the operands differ, a value representing each operand
- ('-1' if the operand is less than zero, '0' if the operand is zero or
- negative zero, or '1' if the operand is greater than zero) is used in
- place of that operand for the comparison instead of the actual
- operand.
+ If the signs of the operands differ, a value representing each
+ operand ('-1' if the operand is less than zero, '0' if the operand
+ is zero or negative zero, or '1' if the operand is greater than
+ zero) is used in place of that operand for the comparison instead of
+ the actual operand.
- The comparison is then effected by subtracting the second operand from
- the first and then returning a value according to the result of the
- subtraction: '-1' if the result is less than zero, '0' if the result is
- zero or negative zero, or '1' if the result is greater than zero.
+ The comparison is then effected by subtracting the second operand
+ from the first and then returning a value according to the result of
+ the subtraction: '-1' if the result is less than zero, '0' if the
+ result is zero or negative zero, or '1' if the result is greater
+ than zero.
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('3'))
Decimal('-1')
@@ -4240,8 +4244,8 @@ def compare_total(self, a, b):
"""Compares two operands using their abstract representation.
This is not like the standard compare, which use their numerical
- value. Note that a total ordering is defined for all possible abstract
- representations.
+ value. Note that a total ordering is defined for all possible
+ abstract representations.
>>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9'))
Decimal('-1')
@@ -4268,7 +4272,8 @@ def compare_total(self, a, b):
def compare_total_mag(self, a, b):
"""Compares two operands using their abstract representation ignoring
sign.
- Like compare_total, but with operand's sign ignored and assumed to be
0.
+ Like compare_total, but with operand's sign ignored and assumed to
+ be 0.
"""
a = _convert_other(a, raiseit=True)
return a.compare_total_mag(b)
@@ -4926,8 +4931,8 @@ def multiply(self, a, b):
If either operand is a special value then the general rules apply.
Otherwise, the operands are multiplied together
- ('long multiplication'), resulting in a number which may be as long as
- the sum of the lengths of the two operands.
+ ('long multiplication'), resulting in a number which may be as long
+ as the sum of the lengths of the two operands.
>>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
Decimal('3.60')
@@ -5203,19 +5208,19 @@ def quantize(self, a, b):
"""Returns a value equal to 'a' (rounded), having the exponent of 'b'.
The coefficient of the result is derived from that of the left-hand
- operand. It may be rounded using the current rounding setting (if the
- exponent is being increased), multiplied by a positive power of ten (if
- the exponent is being decreased), or is unchanged (if the exponent is
- already equal to that of the right-hand operand).
+ operand. It may be rounded using the current rounding setting (if
+ the exponent is being increased), multiplied by a positive power of
+ ten (if the exponent is being decreased), or is unchanged (if the
+ exponent is already equal to that of the right-hand operand).
Unlike other operations, if the length of the coefficient after the
quantize operation would be greater than precision then an Invalid
- operation condition is raised. This guarantees that, unless there is
- an error condition, the exponent of the result of a quantize is always
- equal to that of the right-hand operand.
+ operation condition is raised. This guarantees that, unless there
+ is an error condition, the exponent of the result of a quantize is
+ always equal to that of the right-hand operand.
- Also unlike other operations, quantize will never raise Underflow, even
- if the result is subnormal and inexact.
+ Also unlike other operations, quantize will never raise Underflow,
+ even if the result is subnormal and inexact.
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))
Decimal('2.170')
@@ -5269,13 +5274,13 @@ def remainder(self, a, b):
"""Returns the remainder from integer division.
The result is the residue of the dividend after the operation of
- calculating integer division as described for divide-integer, rounded
- to precision digits if necessary. The sign of the result, if
- non-zero, is the same as that of the original dividend.
+ calculating integer division as described for divide-integer,
+ rounded to precision digits if necessary. The sign of the result,
+ if non-zero, is the same as that of the original dividend.
- This operation will fail under the same conditions as integer division
- (that is, if integer division on the same two operands would fail, the
- remainder cannot be calculated).
+ This operation will fail under the same conditions as integer
+ division (that is, if integer division on the same two operands
+ would fail, the remainder cannot be calculated).
>>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3'))
Decimal('2.1')
@@ -5309,9 +5314,9 @@ def remainder_near(self, a, b):
is chosen). If the result is equal to 0 then its sign will be the
sign of a.
- This operation will fail under the same conditions as integer division
- (that is, if integer division on the same two operands would fail, the
- remainder cannot be calculated).
+ This operation will fail under the same conditions as integer
+ division (that is, if integer division on the same two operands
+ would fail, the remainder cannot be calculated).
>>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))
Decimal('-0.9')
@@ -5369,8 +5374,8 @@ def rotate(self, a, b):
def same_quantum(self, a, b):
"""Returns True if the two operands have the same exponent.
- The result is never affected by either the sign or the coefficient of
- either operand.
+ The result is never affected by either the sign or the coefficient
+ of either operand.
>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
False
@@ -5442,8 +5447,8 @@ def shift(self, a, b):
def sqrt(self, a):
"""Square root of a non-negative number to context precision.
- If the result must be inexact, it is rounded using the round-half-even
- algorithm.
+ If the result must be inexact, it is rounded using the
+ round-half-even algorithm.
>>> ExtendedContext.sqrt(Decimal('0'))
Decimal('0')
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index 0a8308d9ebce7a7..2760792a3fe18ed 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -939,13 +939,13 @@ _decimal.Context.Etop
Return a value equal to Emax - prec + 1.
-This is the maximum exponent if the _clamp field of the context is set
-to 1 (IEEE clamp mode). Etop() must not be negative.
+This is the maximum exponent if the _clamp field of the context is
+set to 1 (IEEE clamp mode). Etop() must not be negative.
[clinic start generated code]*/
static PyObject *
_decimal_Context_Etop_impl(PyObject *self)
-/*[clinic end generated code: output=f0a3f6e1b829074e input=838a4409316ec728]*/
+/*[clinic end generated code: output=f0a3f6e1b829074e input=35b9defc69d5e5d1]*/
{
return PyLong_FromSsize_t(mpd_etop(CTX(self)));
}
@@ -2997,6 +2997,7 @@ PyDecType_FromSequenceExact(PyTypeObject *type, PyObject
*v,
PyDecType_FromSequenceExact((st)->PyDec_Type, sequence, context)
/*[clinic input]
+@permit_long_docstring_body
@classmethod
_decimal.Decimal.from_float
@@ -3022,7 +3023,7 @@ Decimal.from_float(0.1) is not the same as Decimal('0.1').
static PyObject *
_decimal_Decimal_from_float_impl(PyTypeObject *type, PyTypeObject *cls,
PyObject *pyfloat)
-/*[clinic end generated code: output=fcb7d55d2f9dc790 input=03bc8dbe963e52ca]*/
+/*[clinic end generated code: output=fcb7d55d2f9dc790 input=29abf05dd8fe79e4]*/
{
PyObject *context;
PyObject *result;
@@ -3068,6 +3069,8 @@ PyDecType_FromNumberExact(PyTypeObject *type,
PyTypeObject *cls,
}
/*[clinic input]
+@permit_long_summary
+@permit_long_docstring_body
@classmethod
_decimal.Decimal.from_number
@@ -3088,7 +3091,7 @@ Class method that converts a real number to a decimal
number, exactly.
static PyObject *
_decimal_Decimal_from_number_impl(PyTypeObject *type, PyTypeObject *cls,
PyObject *number)
-/*[clinic end generated code: output=4d3ec722b7acfd8b input=271cb4feb3148804]*/
+/*[clinic end generated code: output=4d3ec722b7acfd8b input=34ff3696955d3def]*/
{
PyObject *context;
PyObject *result;
@@ -3959,6 +3962,7 @@ dec_as_long(PyObject *dec, PyObject *context, int round)
}
/*[clinic input]
+@permit_long_summary
_decimal.Decimal.as_integer_ratio
cls: defining_class
@@ -3971,7 +3975,7 @@ Raise OverflowError on infinities and a ValueError on
NaNs.
static PyObject *
_decimal_Decimal_as_integer_ratio_impl(PyObject *self, PyTypeObject *cls)
-/*[clinic end generated code: output=eb49c512701f844b input=07e33d8852184761]*/
+/*[clinic end generated code: output=eb49c512701f844b input=136f1dc585ca8d80]*/
{
PyObject *numerator = NULL;
PyObject *denominator = NULL;
@@ -4146,17 +4150,17 @@ _decimal.Decimal.to_integral_exact =
_decimal.Decimal.to_integral_value
Round to the nearest integer.
-Decimal.to_integral_exact() signals Inexact or Rounded as appropriate
-if rounding occurs. The rounding mode is determined by the rounding
-parameter if given, else by the given context. If neither parameter is
-given, then the rounding mode of the current default context is used.
+This method signals Inexact or Rounded as appropriate if rounding
+occurs. The rounding mode is determined by the rounding parameter
+if given, else by the given context. If neither parameter is given,
+then the rounding mode of the current default context is used.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_to_integral_exact_impl(PyObject *self, PyTypeObject *cls,
PyObject *rounding,
PyObject *context)
-/*[clinic end generated code: output=543a39a02eea9917 input=fabce7a744b8087c]*/
+/*[clinic end generated code: output=543a39a02eea9917 input=d4d8abe543393de1]*/
{
PyObject *result;
uint32_t status = 0;
@@ -4791,13 +4795,14 @@ _decimal.Decimal.sqrt = _decimal.Decimal.exp
Return the square root of the argument to full precision.
-The result is correctly rounded using the ROUND_HALF_EVEN rounding mode.
+The result is correctly rounded using the ROUND_HALF_EVEN rounding
+mode.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_sqrt_impl(PyObject *self, PyTypeObject *cls,
PyObject *context)
-/*[clinic end generated code: output=deb1280077b5e586 input=3a76afbd39dc20b9]*/
+/*[clinic end generated code: output=deb1280077b5e586 input=c565a7216e9605e7]*/
Dec_UnaryFuncVA(mpd_qsqrt)
/* Binary arithmetic functions, optional context arg */
@@ -4853,6 +4858,7 @@ _decimal_Decimal_max_impl(PyObject *self, PyTypeObject
*cls, PyObject *other,
Dec_BinaryFuncVA(mpd_qmax)
/*[clinic input]
+@permit_long_summary
_decimal.Decimal.max_mag = _decimal.Decimal.compare
As the max() method, but compares the absolute values of the operands.
@@ -4861,7 +4867,7 @@ As the max() method, but compares the absolute values of
the operands.
static PyObject *
_decimal_Decimal_max_mag_impl(PyObject *self, PyTypeObject *cls,
PyObject *other, PyObject *context)
-/*[clinic end generated code: output=f71f2c27d9bc7cac input=88b105e66cf138c5]*/
+/*[clinic end generated code: output=f71f2c27d9bc7cac input=5f81b9da49b45e5d]*/
Dec_BinaryFuncVA(mpd_qmax_mag)
/*[clinic input]
@@ -4880,6 +4886,7 @@ _decimal_Decimal_min_impl(PyObject *self, PyTypeObject
*cls, PyObject *other,
Dec_BinaryFuncVA(mpd_qmin)
/*[clinic input]
+@permit_long_summary
_decimal.Decimal.min_mag = _decimal.Decimal.compare
As the min() method, but compares the absolute values of the operands.
@@ -4888,7 +4895,7 @@ As the min() method, but compares the absolute values of
the operands.
static PyObject *
_decimal_Decimal_min_mag_impl(PyObject *self, PyTypeObject *cls,
PyObject *other, PyObject *context)
-/*[clinic end generated code: output=018562ad1c22aae3 input=351fa3c0e592746a]*/
+/*[clinic end generated code: output=018562ad1c22aae3 input=94c29817c7f16db7]*/
Dec_BinaryFuncVA(mpd_qmin_mag)
/*[clinic input]
@@ -4896,16 +4903,16 @@ _decimal.Decimal.next_toward = _decimal.Decimal.compare
Returns the number closest to self, in the direction towards other.
-If the two operands are unequal, return the number closest to the first
-operand in the direction of the second operand. If both operands are
-numerically equal, return a copy of the first operand with the sign set
-to be the same as the sign of the second operand.
+If the two operands are unequal, return the number closest to the
+first operand in the direction of the second operand. If both
+operands are numerically equal, return a copy of the first operand
+with the sign set to be the same as the sign of the second operand.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_next_toward_impl(PyObject *self, PyTypeObject *cls,
PyObject *other, PyObject *context)
-/*[clinic end generated code: output=71d879bca8bc1019 input=fdf0091ea6e9e416]*/
+/*[clinic end generated code: output=71d879bca8bc1019 input=adc5d453fc140341]*/
Dec_BinaryFuncVA(mpd_qnext_toward)
/*[clinic input]
@@ -4914,10 +4921,10 @@ _decimal.Decimal.remainder_near =
_decimal.Decimal.compare
Return the remainder from dividing self by other.
This differs from self % other in that the sign of the remainder is
-chosen so as to minimize its absolute value. More precisely, the return
-value is self - n * other where n is the integer nearest to the exact
-value of self / other, and if two integers are equally near then the
-even one is chosen.
+chosen so as to minimize its absolute value. More precisely, the
+return value is self - n * other where n is the integer nearest to
+the exact value of self / other, and if two integers are equally
+near then the even one is chosen.
If the result is zero then its sign will be the sign of self.
[clinic start generated code]*/
@@ -4925,7 +4932,7 @@ If the result is zero then its sign will be the sign of
self.
static PyObject *
_decimal_Decimal_remainder_near_impl(PyObject *self, PyTypeObject *cls,
PyObject *other, PyObject *context)
-/*[clinic end generated code: output=d3fbb4985f2077fa input=eb5a8dfe3470b794]*/
+/*[clinic end generated code: output=d3fbb4985f2077fa input=dcb66d4afa0c77c3]*/
Dec_BinaryFuncVA(mpd_qrem_near)
/* Ternary arithmetic functions, optional context arg */
@@ -4992,6 +4999,7 @@ _decimal_Decimal_is_infinite_impl(PyObject *self)
Dec_BoolFunc(mpd_isinfinite)
/*[clinic input]
+@permit_long_summary
_decimal.Decimal.is_nan
Return True if the argument is a (quiet or signaling) NaN, else False.
@@ -4999,7 +5007,7 @@ Return True if the argument is a (quiet or signaling)
NaN, else False.
static PyObject *
_decimal_Decimal_is_nan_impl(PyObject *self)
-/*[clinic end generated code: output=b704e8b49a164388 input=795e5dac85976994]*/
+/*[clinic end generated code: output=b704e8b49a164388 input=b7d8f0d59fe2332a]*/
Dec_BoolFunc(mpd_isnan)
/*[clinic input]
@@ -5153,13 +5161,13 @@ _decimal.Decimal.radix
Return Decimal(10).
-This is the radix (base) in which the Decimal class does
-all its arithmetic. Included for compatibility with the specification.
+This is the radix (base) in which the Decimal class does all its
+arithmetic. Included for compatibility with the specification.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_radix_impl(PyObject *self, PyTypeObject *cls)
-/*[clinic end generated code: output=40a3bc7ec3d99228 input=b0d4cb9f870bbac1]*/
+/*[clinic end generated code: output=40a3bc7ec3d99228 input=d1cdbdbbbdefdec2]*/
{
decimal_state *state = PyType_GetModuleState(cls);
return _dec_mpd_radix(state);
@@ -5250,15 +5258,15 @@ _decimal.Decimal.logb = _decimal.Decimal.exp
Return the adjusted exponent of the operand as a Decimal instance.
-If the operand is a zero, then Decimal('-Infinity') is returned and the
-DivisionByZero condition is raised. If the operand is an infinity then
-Decimal('Infinity') is returned.
+If the operand is a zero, then Decimal('-Infinity') is returned and
+the DivisionByZero condition is raised. If the operand is an
+infinity then Decimal('Infinity') is returned.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_logb_impl(PyObject *self, PyTypeObject *cls,
PyObject *context)
-/*[clinic end generated code: output=36b0bda09e934245 input=a8df027d1b8a2b17]*/
+/*[clinic end generated code: output=36b0bda09e934245 input=eeafa6bbf8d8a013]*/
Dec_UnaryFuncVA(mpd_qlogb)
/*[clinic input]
@@ -5280,14 +5288,15 @@ The returned value is one of the following ten strings:
* '+Normal', indicating that the operand is a positive normal
number.
* '+Infinity', indicating that the operand is positive infinity.
- * 'NaN', indicating that the operand is a quiet NaN (Not a Number).
+ * 'NaN', indicating that the operand is a quiet NaN (Not a
+ Number).
* 'sNaN', indicating that the operand is a signaling NaN.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_number_class_impl(PyObject *self, PyTypeObject *cls,
PyObject *context)
-/*[clinic end generated code: output=1ac82412e0849c52 input=447095d2677fa0ca]*/
+/*[clinic end generated code: output=1ac82412e0849c52 input=0b59852b43c521aa]*/
{
const char *cp;
@@ -5303,19 +5312,19 @@ _decimal.Decimal.to_eng_string = _decimal.Decimal.exp
Convert to an engineering-type string.
-Engineering notation has an exponent which is a multiple of 3, so there
-are up to 3 digits left of the decimal place. For example,
+Engineering notation has an exponent which is a multiple of 3, so
+there are up to 3 digits left of the decimal place. For example,
Decimal('123E+1') is converted to Decimal('1.23E+3').
-The value of context.capitals determines whether the exponent sign is
-lower or upper case. Otherwise, the context does not affect the
+The value of context.capitals determines whether the exponent sign
+is lower or upper case. Otherwise, the context does not affect the
operation.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_to_eng_string_impl(PyObject *self, PyTypeObject *cls,
PyObject *context)
-/*[clinic end generated code: output=901f128d437ae5c0 input=b2cb7e01e268e45d]*/
+/*[clinic end generated code: output=901f128d437ae5c0 input=111db4de6561f211]*/
{
PyObject *result;
mpd_ssize_t size;
@@ -5343,31 +5352,31 @@ _decimal.Decimal.compare_total =
_decimal.Decimal.compare
Compare two operands using their abstract representation.
-Similar to the compare() method, but the result
-gives a total ordering on Decimal instances. Two Decimal instances with
-the same numeric value but different representations compare unequal
-in this ordering:
+Similar to the compare() method, but the result gives a total
+ordering on Decimal instances. Two Decimal instances with the same
+numeric value but different representations compare unequal in this
+ordering:
>>> Decimal('12.0').compare_total(Decimal('12'))
Decimal('-1')
-Quiet and signaling NaNs are also included in the total ordering. The
-result of this function is Decimal('0') if both operands have the same
-representation, Decimal('-1') if the first operand is lower in the
-total order than the second, and Decimal('1') if the first operand is
-higher in the total order than the second operand. See the
-specification for details of the total order.
+Quiet and signaling NaNs are also included in the total ordering.
+The result of this function is Decimal('0') if both operands have
+the same representation, Decimal('-1') if the first operand is lower
+in the total order than the second, and Decimal('1') if the first
+operand is higher in the total order than the second operand. See
+the specification for details of the total order.
This operation is unaffected by context and is quiet: no flags are
-changed and no rounding is performed. As an exception, the C version
-may raise InvalidOperation if the second operand cannot be converted
-exactly.
+changed and no rounding is performed. As an exception, the C
+version may raise InvalidOperation if the second operand cannot be
+converted exactly.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_compare_total_impl(PyObject *self, PyTypeObject *cls,
PyObject *other, PyObject *context)
-/*[clinic end generated code: output=83649010bad7815f input=6f3111ec5fdbf3c1]*/
+/*[clinic end generated code: output=83649010bad7815f input=d795bf204b9ff2a8]*/
Dec_BinaryFuncVA_NO_CTX(mpd_compare_total)
/*[clinic input]
@@ -5516,18 +5525,19 @@ _decimal.Decimal.rotate = _decimal.Decimal.compare
Returns a rotated copy of self's digits, value-of-other times.
-The second operand must be an integer in the range -precision through
-precision. The absolute value of the second operand gives the number of
-places to rotate. If the second operand is positive then rotation is to
-the left; otherwise rotation is to the right. The coefficient of the
-first operand is padded on the left with zeros to length precision if
-necessary. The sign and exponent of the first operand are unchanged.
+The second operand must be an integer in the range -precision
+through precision. The absolute value of the second operand gives
+the number of places to rotate. If the second operand is positive
+then rotation is to the left; otherwise rotation is to the right.
+The coefficient of the first operand is padded on the left with
+zeros to length precision if necessary. The sign and exponent of
+the first operand are unchanged.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_rotate_impl(PyObject *self, PyTypeObject *cls,
PyObject *other, PyObject *context)
-/*[clinic end generated code: output=09f2737082882b83 input=cde7b032eac43f0b]*/
+/*[clinic end generated code: output=09f2737082882b83 input=4bc840d51842934c]*/
Dec_BinaryFuncVA(mpd_qrotate)
/*[clinic input]
@@ -5550,18 +5560,18 @@ _decimal.Decimal.shift = _decimal.Decimal.compare
Returns a shifted copy of self's digits, value-of-other times.
-The second operand must be an integer in the range -precision through
-precision. The absolute value of the second operand gives the number
-of places to shift. If the second operand is positive, then the shift
-is to the left; otherwise the shift is to the right. Digits shifted
-into the coefficient are zeros. The sign and exponent of the first
-operand are unchanged.
+The second operand must be an integer in the range -precision
+through precision. The absolute value of the second operand gives
+the number of places to shift. If the second operand is positive,
+then the shift is to the left; otherwise the shift is to the right.
+Digits shifted into the coefficient are zeros. The sign and
+exponent of the first operand are unchanged.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_shift_impl(PyObject *self, PyTypeObject *cls,
PyObject *other, PyObject *context)
-/*[clinic end generated code: output=82e061a0d9ecc4f5 input=501759c2522cb78e]*/
+/*[clinic end generated code: output=82e061a0d9ecc4f5 input=c05f3fd69fc1f9f9]*/
Dec_BinaryFuncVA(mpd_qshift)
/*[clinic input]
@@ -5589,18 +5599,18 @@ that of the right-hand operand.
Also unlike other operations, quantize never signals Underflow, even
if the result is subnormal and inexact.
-If the exponent of the second operand is larger than that of the first,
-then rounding may be necessary. In this case, the rounding mode is
-determined by the rounding argument if given, else by the given context
-argument; if neither argument is given, the rounding mode of the
-current thread's context is used.
+If the exponent of the second operand is larger than that of the
+first, then rounding may be necessary. In this case, the rounding
+mode is determined by the rounding argument if given, else by the
+given context argument; if neither argument is given, the rounding
+mode of the current thread's context is used.
[clinic start generated code]*/
static PyObject *
_decimal_Decimal_quantize_impl(PyObject *self, PyTypeObject *cls,
PyObject *w, PyObject *rounding,
PyObject *context)
-/*[clinic end generated code: output=fc51edf458559913 input=1166e6311e047b74]*/
+/*[clinic end generated code: output=fc51edf458559913 input=7838b0a5f684adb8]*/
{
PyObject *a, *b;
PyObject *result;
@@ -6629,14 +6639,14 @@ _decimal.Context.remainder_near = _decimal.Context.add
Return x - y * n.
-Here n is the integer nearest the exact value of x / y (if the result
-is 0 then its sign will be the sign of x).
+Here n is the integer nearest the exact value of x / y (if the
+result is 0 then its sign will be the sign of x).
[clinic start generated code]*/
static PyObject *
_decimal_Context_remainder_near_impl(PyObject *context, PyTypeObject *cls,
PyObject *x, PyObject *y)
-/*[clinic end generated code: output=7f18c535a12cf8ac input=bafb6327bb314c5c]*/
+/*[clinic end generated code: output=7f18c535a12cf8ac input=60342558000d4be6]*/
DecCtx_BinaryFunc(mpd_qrem_near)
/*[clinic input]
@@ -6723,13 +6733,14 @@ restrictions hold:
* all three arguments must be integral
* 'b' must be nonnegative
* at least one of 'a' or 'b' must be nonzero
- * modulo must be nonzero and less than 10**prec in absolute value
+ * modulo must be nonzero and less than 10**prec in absolute
+ value
[clinic start generated code]*/
static PyObject *
_decimal_Context_power_impl(PyObject *context, PyTypeObject *cls,
PyObject *base, PyObject *exp, PyObject *mod)
-/*[clinic end generated code: output=d06d40c37cdd69dc input=2a70edd03317c666]*/
+/*[clinic end generated code: output=d06d40c37cdd69dc input=178a254468ec189b]*/
{
PyObject *a, *b, *c = NULL;
PyObject *result;
@@ -7276,6 +7287,7 @@ _decimal_Context_copy_sign_impl(PyObject *context,
PyTypeObject *cls,
}
/*[clinic input]
+@permit_long_docstring_body
_decimal.Context.logical_and = _decimal.Context.add
Applies the logical operation 'and' between each operand's digits.
@@ -7305,7 +7317,7 @@ The operands must be both logical numbers.
static PyObject *
_decimal_Context_logical_and_impl(PyObject *context, PyTypeObject *cls,
PyObject *x, PyObject *y)
-/*[clinic end generated code: output=009dfa08ecaa2ac8 input=bcb7d3d6ab7530de]*/
+/*[clinic end generated code: output=009dfa08ecaa2ac8 input=9f8a93a31b9d7088]*/
DecCtx_BinaryFunc(mpd_qand)
/*[clinic input]
@@ -7342,6 +7354,7 @@ _decimal_Context_logical_or_impl(PyObject *context,
PyTypeObject *cls,
DecCtx_BinaryFunc(mpd_qor)
/*[clinic input]
+@permit_long_docstring_body
_decimal.Context.logical_xor = _decimal.Context.add
Applies the logical operation 'xor' between each operand's digits.
@@ -7371,7 +7384,7 @@ The operands must be both logical numbers.
static PyObject *
_decimal_Context_logical_xor_impl(PyObject *context, PyTypeObject *cls,
PyObject *x, PyObject *y)
-/*[clinic end generated code: output=23cd81fdcd865d5a input=fcaaf828c1d2d089]*/
+/*[clinic end generated code: output=23cd81fdcd865d5a input=119412854ae58440]*/
DecCtx_BinaryFunc(mpd_qxor)
/*[clinic input]
diff --git a/Modules/_decimal/clinic/_decimal.c.h
b/Modules/_decimal/clinic/_decimal.c.h
index b09200845d12e98..c803006ad443825 100644
--- a/Modules/_decimal/clinic/_decimal.c.h
+++ b/Modules/_decimal/clinic/_decimal.c.h
@@ -36,8 +36,8 @@ PyDoc_STRVAR(_decimal_Context_Etop__doc__,
"\n"
"Return a value equal to Emax - prec + 1.\n"
"\n"
-"This is the maximum exponent if the _clamp field of the context is set\n"
-"to 1 (IEEE clamp mode). Etop() must not be negative.");
+"This is the maximum exponent if the _clamp field of the context is\n"
+"set to 1 (IEEE clamp mode). Etop() must not be negative.");
#define _DECIMAL_CONTEXT_ETOP_METHODDEF \
{"Etop", (PyCFunction)_decimal_Context_Etop, METH_NOARGS,
_decimal_Context_Etop__doc__},
@@ -1092,10 +1092,10 @@ PyDoc_STRVAR(_decimal_Decimal_to_integral_exact__doc__,
"\n"
"Round to the nearest integer.\n"
"\n"
-"Decimal.to_integral_exact() signals Inexact or Rounded as appropriate\n"
-"if rounding occurs. The rounding mode is determined by the rounding\n"
-"parameter if given, else by the given context. If neither parameter is\n"
-"given, then the rounding mode of the current default context is used.");
+"This method signals Inexact or Rounded as appropriate if rounding\n"
+"occurs. The rounding mode is determined by the rounding parameter\n"
+"if given, else by the given context. If neither parameter is given,\n"
+"then the rounding mode of the current default context is used.");
#define _DECIMAL_DECIMAL_TO_INTEGRAL_EXACT_METHODDEF \
{"to_integral_exact",
_PyCFunction_CAST(_decimal_Decimal_to_integral_exact),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS,
_decimal_Decimal_to_integral_exact__doc__},
@@ -1638,7 +1638,8 @@ PyDoc_STRVAR(_decimal_Decimal_sqrt__doc__,
"\n"
"Return the square root of the argument to full precision.\n"
"\n"
-"The result is correctly rounded using the ROUND_HALF_EVEN rounding mode.");
+"The result is correctly rounded using the ROUND_HALF_EVEN rounding\n"
+"mode.");
#define _DECIMAL_DECIMAL_SQRT_METHODDEF \
{"sqrt", _PyCFunction_CAST(_decimal_Decimal_sqrt),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_sqrt__doc__},
@@ -2113,10 +2114,10 @@ PyDoc_STRVAR(_decimal_Decimal_next_toward__doc__,
"\n"
"Returns the number closest to self, in the direction towards other.\n"
"\n"
-"If the two operands are unequal, return the number closest to the first\n"
-"operand in the direction of the second operand. If both operands are\n"
-"numerically equal, return a copy of the first operand with the sign set\n"
-"to be the same as the sign of the second operand.");
+"If the two operands are unequal, return the number closest to the\n"
+"first operand in the direction of the second operand. If both\n"
+"operands are numerically equal, return a copy of the first operand\n"
+"with the sign set to be the same as the sign of the second operand.");
#define _DECIMAL_DECIMAL_NEXT_TOWARD_METHODDEF \
{"next_toward", _PyCFunction_CAST(_decimal_Decimal_next_toward),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_next_toward__doc__},
@@ -2185,10 +2186,10 @@ PyDoc_STRVAR(_decimal_Decimal_remainder_near__doc__,
"Return the remainder from dividing self by other.\n"
"\n"
"This differs from self % other in that the sign of the remainder is\n"
-"chosen so as to minimize its absolute value. More precisely, the return\n"
-"value is self - n * other where n is the integer nearest to the exact\n"
-"value of self / other, and if two integers are equally near then the\n"
-"even one is chosen.\n"
+"chosen so as to minimize its absolute value. More precisely, the\n"
+"return value is self - n * other where n is the integer nearest to\n"
+"the exact value of self / other, and if two integers are equally\n"
+"near then the even one is chosen.\n"
"\n"
"If the result is zero then its sign will be the sign of self.");
@@ -2671,8 +2672,8 @@ PyDoc_STRVAR(_decimal_Decimal_radix__doc__,
"\n"
"Return Decimal(10).\n"
"\n"
-"This is the radix (base) in which the Decimal class does\n"
-"all its arithmetic. Included for compatibility with the specification.");
+"This is the radix (base) in which the Decimal class does all its\n"
+"arithmetic. Included for compatibility with the specification.");
#define _DECIMAL_DECIMAL_RADIX_METHODDEF \
{"radix", _PyCFunction_CAST(_decimal_Decimal_radix),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_radix__doc__},
@@ -2812,9 +2813,9 @@ PyDoc_STRVAR(_decimal_Decimal_logb__doc__,
"\n"
"Return the adjusted exponent of the operand as a Decimal instance.\n"
"\n"
-"If the operand is a zero, then Decimal(\'-Infinity\') is returned and the\n"
-"DivisionByZero condition is raised. If the operand is an infinity then\n"
-"Decimal(\'Infinity\') is returned.");
+"If the operand is a zero, then Decimal(\'-Infinity\') is returned and\n"
+"the DivisionByZero condition is raised. If the operand is an\n"
+"infinity then Decimal(\'Infinity\') is returned.");
#define _DECIMAL_DECIMAL_LOGB_METHODDEF \
{"logb", _PyCFunction_CAST(_decimal_Decimal_logb),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_logb__doc__},
@@ -2894,7 +2895,8 @@ PyDoc_STRVAR(_decimal_Decimal_number_class__doc__,
" * \'+Normal\', indicating that the operand is a positive normal\n"
" number.\n"
" * \'+Infinity\', indicating that the operand is positive infinity.\n"
-" * \'NaN\', indicating that the operand is a quiet NaN (Not a Number).\n"
+" * \'NaN\', indicating that the operand is a quiet NaN (Not a\n"
+" Number).\n"
" * \'sNaN\', indicating that the operand is a signaling NaN.");
#define _DECIMAL_DECIMAL_NUMBER_CLASS_METHODDEF \
@@ -2961,12 +2963,12 @@ PyDoc_STRVAR(_decimal_Decimal_to_eng_string__doc__,
"\n"
"Convert to an engineering-type string.\n"
"\n"
-"Engineering notation has an exponent which is a multiple of 3, so there\n"
-"are up to 3 digits left of the decimal place. For example,\n"
+"Engineering notation has an exponent which is a multiple of 3, so\n"
+"there are up to 3 digits left of the decimal place. For example,\n"
"Decimal(\'123E+1\') is converted to Decimal(\'1.23E+3\').\n"
"\n"
-"The value of context.capitals determines whether the exponent sign is\n"
-"lower or upper case. Otherwise, the context does not affect the\n"
+"The value of context.capitals determines whether the exponent sign\n"
+"is lower or upper case. Otherwise, the context does not affect the\n"
"operation.");
#define _DECIMAL_DECIMAL_TO_ENG_STRING_METHODDEF \
@@ -3033,25 +3035,25 @@ PyDoc_STRVAR(_decimal_Decimal_compare_total__doc__,
"\n"
"Compare two operands using their abstract representation.\n"
"\n"
-"Similar to the compare() method, but the result\n"
-"gives a total ordering on Decimal instances. Two Decimal instances with\n"
-"the same numeric value but different representations compare unequal\n"
-"in this ordering:\n"
+"Similar to the compare() method, but the result gives a total\n"
+"ordering on Decimal instances. Two Decimal instances with the same\n"
+"numeric value but different representations compare unequal in this\n"
+"ordering:\n"
"\n"
" >>> Decimal(\'12.0\').compare_total(Decimal(\'12\'))\n"
" Decimal(\'-1\')\n"
"\n"
-"Quiet and signaling NaNs are also included in the total ordering. The\n"
-"result of this function is Decimal(\'0\') if both operands have the same\n"
-"representation, Decimal(\'-1\') if the first operand is lower in the\n"
-"total order than the second, and Decimal(\'1\') if the first operand is\n"
-"higher in the total order than the second operand. See the\n"
-"specification for details of the total order.\n"
+"Quiet and signaling NaNs are also included in the total ordering.\n"
+"The result of this function is Decimal(\'0\') if both operands have\n"
+"the same representation, Decimal(\'-1\') if the first operand is lower\n"
+"in the total order than the second, and Decimal(\'1\') if the first\n"
+"operand is higher in the total order than the second operand. See\n"
+"the specification for details of the total order.\n"
"\n"
"This operation is unaffected by context and is quiet: no flags are\n"
-"changed and no rounding is performed. As an exception, the C version\n"
-"may raise InvalidOperation if the second operand cannot be converted\n"
-"exactly.");
+"changed and no rounding is performed. As an exception, the C\n"
+"version may raise InvalidOperation if the second operand cannot be\n"
+"converted exactly.");
#define _DECIMAL_DECIMAL_COMPARE_TOTAL_METHODDEF \
{"compare_total", _PyCFunction_CAST(_decimal_Decimal_compare_total),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_compare_total__doc__},
@@ -3544,12 +3546,13 @@ PyDoc_STRVAR(_decimal_Decimal_rotate__doc__,
"\n"
"Returns a rotated copy of self\'s digits, value-of-other times.\n"
"\n"
-"The second operand must be an integer in the range -precision through\n"
-"precision. The absolute value of the second operand gives the number of\n"
-"places to rotate. If the second operand is positive then rotation is to\n"
-"the left; otherwise rotation is to the right. The coefficient of the\n"
-"first operand is padded on the left with zeros to length precision if\n"
-"necessary. The sign and exponent of the first operand are unchanged.");
+"The second operand must be an integer in the range -precision\n"
+"through precision. The absolute value of the second operand gives\n"
+"the number of places to rotate. If the second operand is positive\n"
+"then rotation is to the left; otherwise rotation is to the right.\n"
+"The coefficient of the first operand is padded on the left with\n"
+"zeros to length precision if necessary. The sign and exponent of\n"
+"the first operand are unchanged.");
#define _DECIMAL_DECIMAL_ROTATE_METHODDEF \
{"rotate", _PyCFunction_CAST(_decimal_Decimal_rotate),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_rotate__doc__},
@@ -3686,12 +3689,12 @@ PyDoc_STRVAR(_decimal_Decimal_shift__doc__,
"\n"
"Returns a shifted copy of self\'s digits, value-of-other times.\n"
"\n"
-"The second operand must be an integer in the range -precision through\n"
-"precision. The absolute value of the second operand gives the number\n"
-"of places to shift. If the second operand is positive, then the shift\n"
-"is to the left; otherwise the shift is to the right. Digits shifted\n"
-"into the coefficient are zeros. The sign and exponent of the first\n"
-"operand are unchanged.");
+"The second operand must be an integer in the range -precision\n"
+"through precision. The absolute value of the second operand gives\n"
+"the number of places to shift. If the second operand is positive,\n"
+"then the shift is to the left; otherwise the shift is to the right.\n"
+"Digits shifted into the coefficient are zeros. The sign and\n"
+"exponent of the first operand are unchanged.");
#define _DECIMAL_DECIMAL_SHIFT_METHODDEF \
{"shift", _PyCFunction_CAST(_decimal_Decimal_shift),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_shift__doc__},
@@ -3774,11 +3777,11 @@ PyDoc_STRVAR(_decimal_Decimal_quantize__doc__,
"Also unlike other operations, quantize never signals Underflow, even\n"
"if the result is subnormal and inexact.\n"
"\n"
-"If the exponent of the second operand is larger than that of the first,\n"
-"then rounding may be necessary. In this case, the rounding mode is\n"
-"determined by the rounding argument if given, else by the given context\n"
-"argument; if neither argument is given, the rounding mode of the\n"
-"current thread\'s context is used.");
+"If the exponent of the second operand is larger than that of the\n"
+"first, then rounding may be necessary. In this case, the rounding\n"
+"mode is determined by the rounding argument if given, else by the\n"
+"given context argument; if neither argument is given, the rounding\n"
+"mode of the current thread\'s context is used.");
#define _DECIMAL_DECIMAL_QUANTIZE_METHODDEF \
{"quantize", _PyCFunction_CAST(_decimal_Decimal_quantize),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_quantize__doc__},
@@ -5197,8 +5200,8 @@ PyDoc_STRVAR(_decimal_Context_remainder_near__doc__,
"\n"
"Return x - y * n.\n"
"\n"
-"Here n is the integer nearest the exact value of x / y (if the result\n"
-"is 0 then its sign will be the sign of x).");
+"Here n is the integer nearest the exact value of x / y (if the\n"
+"result is 0 then its sign will be the sign of x).");
#define _DECIMAL_CONTEXT_REMAINDER_NEAR_METHODDEF \
{"remainder_near", _PyCFunction_CAST(_decimal_Context_remainder_near),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS,
_decimal_Context_remainder_near__doc__},
@@ -5336,7 +5339,8 @@ PyDoc_STRVAR(_decimal_Context_power__doc__,
" * all three arguments must be integral\n"
" * \'b\' must be nonnegative\n"
" * at least one of \'a\' or \'b\' must be nonzero\n"
-" * modulo must be nonzero and less than 10**prec in absolute value");
+" * modulo must be nonzero and less than 10**prec in absolute\n"
+" value");
#define _DECIMAL_CONTEXT_POWER_METHODDEF \
{"power", _PyCFunction_CAST(_decimal_Context_power),
METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Context_power__doc__},
@@ -6980,4 +6984,4 @@ _decimal_Context_same_quantum(PyObject *context,
PyTypeObject *cls, PyObject *co
#ifndef _DECIMAL_CONTEXT_APPLY_METHODDEF
#define _DECIMAL_CONTEXT_APPLY_METHODDEF
#endif /* !defined(_DECIMAL_CONTEXT_APPLY_METHODDEF) */
-/*[clinic end generated code: output=b288181c82fdc9f1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0eb835634388294e input=a9049054013a1b77]*/
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]