From f1496f8b32c43c512bfa69df55d200e54a0d6a42 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 8 Mar 2023 05:40:42 +0300 Subject: [PATCH 1/4] gh-102431: clarify constraints on arguments of logical_xxx methods --- Lib/_pydecimal.py | 35 +++++++++++++++++++++++++++-------- Modules/_decimal/docstrings.h | 24 ++++++++++++++++-------- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index 2692f2fcba45bf..25d96b99754f34 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -3388,7 +3388,11 @@ def _fill_logical(self, context, opa, opb): return opa, opb def logical_and(self, other, context=None): - """Applies an 'and' operation between self and other's digits.""" + """Applies an 'and' operation between self and other's digits. + + Both self and other should have zero sign and exponent, + and digits either 0 or 1. + """ if context is None: context = getcontext() @@ -3405,14 +3409,21 @@ def logical_and(self, other, context=None): return _dec_from_triple(0, result.lstrip('0') or '0', 0) def logical_invert(self, context=None): - """Invert all its digits.""" + """Invert all its digits. + + The self should have zero sign and exponent, and digits either 0 or 1. + """ if context is None: context = getcontext() return self.logical_xor(_dec_from_triple(0,'1'*context.prec,0), context) def logical_or(self, other, context=None): - """Applies an 'or' operation between self and other's digits.""" + """Applies an 'or' operation between self and other's digits. + + Both self and other should have zero sign and exponent, + and digits either 0 or 1. + """ if context is None: context = getcontext() @@ -3429,7 +3440,11 @@ def logical_or(self, other, context=None): return _dec_from_triple(0, result.lstrip('0') or '0', 0) def logical_xor(self, other, context=None): - """Applies an 'xor' operation between self and other's digits.""" + """Applies an 'xor' operation between self and other's digits. + + Both self and other should have zero sign and exponent, + and digits either 0 or 1. + """ if context is None: context = getcontext() @@ -4752,7 +4767,8 @@ def logb(self, a): def logical_and(self, a, b): """Applies the logical operation 'and' between each operand's digits. - The operands must be both logical numbers. + Both operands should have zero sign and exponent, and + digits either 0 or 1. >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0')) Decimal('0') @@ -4779,7 +4795,8 @@ def logical_and(self, a, b): def logical_invert(self, a): """Invert all the digits in the operand. - The operand must be a logical number. + The operand should have zero sign and exponent, and digits + either 0 or 1. >>> ExtendedContext.logical_invert(Decimal('0')) Decimal('111111111') @@ -4798,7 +4815,8 @@ def logical_invert(self, a): def logical_or(self, a, b): """Applies the logical operation 'or' between each operand's digits. - The operands must be both logical numbers. + Both operands should have zero sign and exponent, and digits + either 0 or 1. >>> ExtendedContext.logical_or(Decimal('0'), Decimal('0')) Decimal('0') @@ -4825,7 +4843,8 @@ def logical_or(self, a, b): def logical_xor(self, a, b): """Applies the logical operation 'xor' between each operand's digits. - The operands must be both logical numbers. + Both operands should have zero sign and exponent, and digits + either 0 or 1. >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0')) Decimal('0') diff --git a/Modules/_decimal/docstrings.h b/Modules/_decimal/docstrings.h index a1823cdd32b74c..6542bfd187a8de 100644 --- a/Modules/_decimal/docstrings.h +++ b/Modules/_decimal/docstrings.h @@ -282,22 +282,26 @@ an infinity then Decimal('Infinity') is returned.\n\ PyDoc_STRVAR(doc_logical_and, "logical_and($self, /, other, context=None)\n--\n\n\ -Return the digit-wise 'and' of the two (logical) operands.\n\ +Return the digit-wise 'and' of the two (logical) operands,\n\ +which both have zero sign and exponent, and digits either 0 or 1.\n\ \n"); PyDoc_STRVAR(doc_logical_invert, "logical_invert($self, /, context=None)\n--\n\n\ -Return the digit-wise inversion of the (logical) operand.\n\ +Return the digit-wise inversion of the (logical) operand,\n\ +which has zero sign and exponent, and digits either 0 or 1.\n\ \n"); PyDoc_STRVAR(doc_logical_or, "logical_or($self, /, other, context=None)\n--\n\n\ -Return the digit-wise 'or' of the two (logical) operands.\n\ +Return the digit-wise 'or' of the two (logical) operands,\n\ +which both have zero sign and exponent, and digits either 0 or 1.\n\ \n"); PyDoc_STRVAR(doc_logical_xor, "logical_xor($self, /, other, context=None)\n--\n\n\ -Return the digit-wise 'exclusive or' of the two (logical) operands.\n\ +Return the digit-wise 'exclusive or' of the two (logical) operands,\n\ +which both have zero sign and exponent, and digits either 0 or 1.\n\ \n"); PyDoc_STRVAR(doc_max, @@ -702,22 +706,26 @@ Return the exponent of the magnitude of the operand's MSD.\n\ PyDoc_STRVAR(doc_ctx_logical_and, "logical_and($self, x, y, /)\n--\n\n\ -Digit-wise and of x and y.\n\ +Digit-wise and of x and y, which both have zero sign\n\ +and exponent, and digits either 0 or 1.\n\ \n"); PyDoc_STRVAR(doc_ctx_logical_invert, "logical_invert($self, x, /)\n--\n\n\ -Invert all digits of x.\n\ +Invert all digits of x, which has zero sign and exponent,\n\ +and digits either 0 or 1.\n\ \n"); PyDoc_STRVAR(doc_ctx_logical_or, "logical_or($self, x, y, /)\n--\n\n\ -Digit-wise or of x and y.\n\ +Digit-wise or of x and y, which both have zero sign\n\ +and exponent, and digits either 0 or 1.\n\ \n"); PyDoc_STRVAR(doc_ctx_logical_xor, "logical_xor($self, x, y, /)\n--\n\n\ -Digit-wise xor of x and y.\n\ +Digit-wise xor of x and y, which both have zero sign\n\ +and exponent, and digits either 0 or 1.\n\ \n"); PyDoc_STRVAR(doc_ctx_max, From b704f1c1faea1ec5133e77c8a205200f84df1d28 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 21 Mar 2023 10:55:18 +0300 Subject: [PATCH 2/4] Sync C/python implementation of the decimal: logical_ops for contexts --- Modules/_decimal/docstrings.h | 88 ++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 12 deletions(-) diff --git a/Modules/_decimal/docstrings.h b/Modules/_decimal/docstrings.h index 6542bfd187a8de..6f3185c6cb0d9f 100644 --- a/Modules/_decimal/docstrings.h +++ b/Modules/_decimal/docstrings.h @@ -706,27 +706,91 @@ Return the exponent of the magnitude of the operand's MSD.\n\ PyDoc_STRVAR(doc_ctx_logical_and, "logical_and($self, x, y, /)\n--\n\n\ -Digit-wise and of x and y, which both have zero sign\n\ -and exponent, and digits either 0 or 1.\n\ -\n"); +Applies the logical operation \'and\' between each operand\'s digits.\n\n\ +Both operands should have zero sign and exponent, and\n\ +digits either 0 or 1.\n\n\ +>>> ExtendedContext.logical_and(Decimal(\'0\'), Decimal(\'0\'))\n\ +Decimal(\'0\')\n\ +>>> ExtendedContext.logical_and(Decimal(\'0\'), Decimal(\'1\'))\n\ +Decimal(\'0\')\n\ +>>> ExtendedContext.logical_and(Decimal(\'1\'), Decimal(\'0\'))\n\ +Decimal(\'0\')\n\ +>>> ExtendedContext.logical_and(Decimal(\'1\'), Decimal(\'1\'))\n\ +Decimal(\'1\')\n\ +>>> ExtendedContext.logical_and(Decimal(\'1100\'), Decimal(\'1010\'))\n\ +Decimal(\'1000\')\n\ +>>> ExtendedContext.logical_and(Decimal(\'1111\'), Decimal(\'10\'))\n\ +Decimal(\'10\')\n\ +>>> ExtendedContext.logical_and(110, 1101)\n\ +Decimal(\'100\')\n\ +>>> ExtendedContext.logical_and(Decimal(110), 1101)\n\ +Decimal(\'100\')\n\ +>>> ExtendedContext.logical_and(110, Decimal(1101))\n\ +Decimal(\'100\')\n"); PyDoc_STRVAR(doc_ctx_logical_invert, "logical_invert($self, x, /)\n--\n\n\ -Invert all digits of x, which has zero sign and exponent,\n\ -and digits either 0 or 1.\n\ -\n"); +Invert all the digits in the operand.\n\n\ +The operand should have zero sign and exponent, and digits\n\ +either 0 or 1.\n\n\ +>>> ExtendedContext.logical_invert(Decimal(\'0\'))\n\ +Decimal(\'111111111\')\n\ +>>> ExtendedContext.logical_invert(Decimal(\'1\'))\n\ +Decimal(\'111111110\')\n\ +>>> ExtendedContext.logical_invert(Decimal(\'111111111\'))\n\ +Decimal(\'0\')\n\ +>>> ExtendedContext.logical_invert(Decimal(\'101010101\'))\n\ +Decimal(\'10101010\')\n\ +>>> ExtendedContext.logical_invert(1101)\n\ +Decimal(\'111110010\')\n"); PyDoc_STRVAR(doc_ctx_logical_or, "logical_or($self, x, y, /)\n--\n\n\ -Digit-wise or of x and y, which both have zero sign\n\ -and exponent, and digits either 0 or 1.\n\ -\n"); +Applies the logical operation \'or\' between each operand\'s digits.\n\n\ +Both operands should have zero sign and exponent, and digits\n\ +either 0 or 1.\n\n\ +>>> ExtendedContext.logical_or(Decimal(\'0\'), Decimal(\'0\'))\n\ +Decimal(\'0\')\n\ +>>> ExtendedContext.logical_or(Decimal(\'0\'), Decimal(\'1\'))\n\ +Decimal(\'1\')\n\ +>>> ExtendedContext.logical_or(Decimal(\'1\'), Decimal(\'0\'))\n\ +Decimal(\'1\')\n\ +>>> ExtendedContext.logical_or(Decimal(\'1\'), Decimal(\'1\'))\n\ +Decimal(\'1\')\n\ +>>> ExtendedContext.logical_or(Decimal(\'1100\'), Decimal(\'1010\'))\n\ +Decimal(\'1110\')\n\ +>>> ExtendedContext.logical_or(Decimal(\'1110\'), Decimal(\'10\'))\n\ +Decimal(\'1110\')\n\ +>>> ExtendedContext.logical_or(110, 1101)\n\ +Decimal(\'1111\')\n\ +>>> ExtendedContext.logical_or(Decimal(110), 1101)\n\ +Decimal(\'1111\')\n\ +>>> ExtendedContext.logical_or(110, Decimal(1101))\n\ +Decimal(\'1111\')\n"); PyDoc_STRVAR(doc_ctx_logical_xor, "logical_xor($self, x, y, /)\n--\n\n\ -Digit-wise xor of x and y, which both have zero sign\n\ -and exponent, and digits either 0 or 1.\n\ -\n"); +Applies the logical operation \'xor\' between each operand\'s digits.\n\n\ +Both operands should have zero sign and exponent, and digits\n\ +either 0 or 1.\n\n\ +>>> ExtendedContext.logical_xor(Decimal(\'0\'), Decimal(\'0\'))\n\ +Decimal(\'0\')\n\ +>>> ExtendedContext.logical_xor(Decimal(\'0\'), Decimal(\'1\'))\n\ +Decimal(\'1\')\n\ +>>> ExtendedContext.logical_xor(Decimal(\'1\'), Decimal(\'0\'))\n\ +Decimal(\'1\')\n\ +>>> ExtendedContext.logical_xor(Decimal(\'1\'), Decimal(\'1\'))\n\ +Decimal(\'0\')\n\ +>>> ExtendedContext.logical_xor(Decimal(\'1100\'), Decimal(\'1010\'))\n\ +Decimal(\'110\')\n\ +>>> ExtendedContext.logical_xor(Decimal(\'1111\'), Decimal(\'10\'))\n\ +Decimal(\'1101\')\n\ +>>> ExtendedContext.logical_xor(110, 1101)\n\ +Decimal(\'1011\')\n\ +>>> ExtendedContext.logical_xor(Decimal(110), 1101)\n\ +Decimal(\'1011\')\n\ +>>> ExtendedContext.logical_xor(110, Decimal(1101))\n\ +Decimal(\'1011\')\n"); PyDoc_STRVAR(doc_ctx_max, "max($self, x, y, /)\n--\n\n\ From 460e8af15414a1fc85c2d57c6e1721a77070f627 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 21 Mar 2023 10:59:46 +0300 Subject: [PATCH 3/4] Add news --- .../next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst diff --git a/Misc/NEWS.d/next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst b/Misc/NEWS.d/next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst new file mode 100644 index 00000000000000..e82ddb6e1011ad --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst @@ -0,0 +1,2 @@ +Clarify constraints for "logical" arguments in methods of +:class:`decimal.Context`. From 50eb822143f7c72a183f36f893d1b5ca2e7410e1 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 14 Oct 2025 13:34:12 +0300 Subject: [PATCH 4/4] address review: use "logical numbers" term --- Lib/_pydecimal.py | 23 ++++++---------- Modules/_decimal/_decimal.c | 39 ++++++++++++---------------- Modules/_decimal/clinic/_decimal.c.h | 25 +++++++----------- 3 files changed, 33 insertions(+), 54 deletions(-) diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index a3d34a77104382..97a629fe92ccec 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -3342,8 +3342,7 @@ def _fill_logical(self, context, opa, opb): def logical_and(self, other, context=None): """Applies an 'and' operation between self and other's digits. - Both self and other should have zero sign and exponent, - and digits either 0 or 1. + Both self and other must be logical numbers. """ if context is None: context = getcontext() @@ -3363,7 +3362,7 @@ def logical_and(self, other, context=None): def logical_invert(self, context=None): """Invert all its digits. - The self should have zero sign and exponent, and digits either 0 or 1. + The self must be logical number. """ if context is None: context = getcontext() @@ -3373,8 +3372,7 @@ def logical_invert(self, context=None): def logical_or(self, other, context=None): """Applies an 'or' operation between self and other's digits. - Both self and other should have zero sign and exponent, - and digits either 0 or 1. + Both self and other must be logical numbers. """ if context is None: context = getcontext() @@ -3394,8 +3392,7 @@ def logical_or(self, other, context=None): def logical_xor(self, other, context=None): """Applies an 'xor' operation between self and other's digits. - Both self and other should have zero sign and exponent, - and digits either 0 or 1. + Both self and other must be logical numbers. """ if context is None: context = getcontext() @@ -4719,8 +4716,7 @@ def logb(self, a): def logical_and(self, a, b): """Applies the logical operation 'and' between each operand's digits. - Both operands should have zero sign and exponent, and - digits either 0 or 1. + The operands must be both logical numbers. >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0')) Decimal('0') @@ -4747,8 +4743,7 @@ def logical_and(self, a, b): def logical_invert(self, a): """Invert all the digits in the operand. - The operand should have zero sign and exponent, and digits - either 0 or 1. + The operand must be a logical number. >>> ExtendedContext.logical_invert(Decimal('0')) Decimal('111111111') @@ -4767,8 +4762,7 @@ def logical_invert(self, a): def logical_or(self, a, b): """Applies the logical operation 'or' between each operand's digits. - Both operands should have zero sign and exponent, and digits - either 0 or 1. + The operands must be both logical numbers. >>> ExtendedContext.logical_or(Decimal('0'), Decimal('0')) Decimal('0') @@ -4795,8 +4789,7 @@ def logical_or(self, a, b): def logical_xor(self, a, b): """Applies the logical operation 'xor' between each operand's digits. - Both operands should have zero sign and exponent, and digits - either 0 or 1. + The operands must be both logical numbers. >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0')) Decimal('0') diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 50926b34e71e0e..4e2a4953126360 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -5237,13 +5237,13 @@ _decimal.Decimal.logical_invert = _decimal.Decimal.exp Invert all its digits. -The self should have zero sign and exponent, and digits either 0 or 1. +The self must be logical number. [clinic start generated code]*/ static PyObject * _decimal_Decimal_logical_invert_impl(PyObject *self, PyTypeObject *cls, PyObject *context) -/*[clinic end generated code: output=c626ed4b104a97b7 input=fb9eb6253e7639e1]*/ +/*[clinic end generated code: output=c626ed4b104a97b7 input=7158d5b525417955]*/ Dec_UnaryFuncVA(mpd_qinvert) /*[clinic input] @@ -5475,14 +5475,13 @@ _decimal.Decimal.logical_and = _decimal.Decimal.compare Applies an 'and' operation between self and other's digits. -Both self and other should have zero sign and exponent, -and digits either 0 or 1. +Both self and other must be logical numbers. [clinic start generated code]*/ static PyObject * _decimal_Decimal_logical_and_impl(PyObject *self, PyTypeObject *cls, PyObject *other, PyObject *context) -/*[clinic end generated code: output=9a4cbb74c180b0bb input=f8857b9b57be75f3]*/ +/*[clinic end generated code: output=9a4cbb74c180b0bb input=f22460f1285782d2]*/ Dec_BinaryFuncVA(mpd_qand) /*[clinic input] @@ -5490,14 +5489,13 @@ _decimal.Decimal.logical_or = _decimal.Decimal.compare Applies an 'or' operation between self and other's digits. -Both self and other should have zero sign and exponent, -and digits either 0 or 1. +Both self and other must be logical numbers. [clinic start generated code]*/ static PyObject * _decimal_Decimal_logical_or_impl(PyObject *self, PyTypeObject *cls, PyObject *other, PyObject *context) -/*[clinic end generated code: output=063c4de18dc41ecb input=4043d61390b2a07d]*/ +/*[clinic end generated code: output=063c4de18dc41ecb input=b5afa1e1fdebdfce]*/ Dec_BinaryFuncVA(mpd_qor) /*[clinic input] @@ -5505,14 +5503,13 @@ _decimal.Decimal.logical_xor = _decimal.Decimal.compare Applies an 'xor' operation between self and other's digits. -Both self and other should have zero sign and exponent, -and digits either 0 or 1. +Both self and other must be logical numbers. [clinic start generated code]*/ static PyObject * _decimal_Decimal_logical_xor_impl(PyObject *self, PyTypeObject *cls, PyObject *other, PyObject *context) -/*[clinic end generated code: output=829b09cb49926ad7 input=faea7766e521bdde]*/ +/*[clinic end generated code: output=829b09cb49926ad7 input=84d722ada08a2da7]*/ Dec_BinaryFuncVA(mpd_qxor) /*[clinic input] @@ -7112,8 +7109,7 @@ _decimal.Context.logical_invert = _decimal.Context.abs Invert all the digits in the operand. -The operand should have zero sign and exponent, and digits -either 0 or 1. +The operand must be a logical number. >>> ExtendedContext.logical_invert(Decimal('0')) Decimal('111111111') @@ -7130,7 +7126,7 @@ either 0 or 1. static PyObject * _decimal_Context_logical_invert_impl(PyObject *context, PyTypeObject *cls, PyObject *x) -/*[clinic end generated code: output=97760277a958e2b0 input=c10bbdfd8d864be6]*/ +/*[clinic end generated code: output=97760277a958e2b0 input=8e568f4c745ab596]*/ DecCtx_UnaryFunc(mpd_qinvert) /*[clinic input] @@ -7289,8 +7285,7 @@ _decimal.Context.logical_and = _decimal.Context.add Applies the logical operation 'and' between each operand's digits. -Both operands should have zero sign and exponent, and -digits either 0 or 1. +The operands must be both logical numbers. >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0')) Decimal('0') @@ -7315,7 +7310,7 @@ digits either 0 or 1. static PyObject * _decimal_Context_logical_and_impl(PyObject *context, PyTypeObject *cls, PyObject *x, PyObject *y) -/*[clinic end generated code: output=009dfa08ecaa2ac8 input=771aebf6de97e246]*/ +/*[clinic end generated code: output=009dfa08ecaa2ac8 input=bcb7d3d6ab7530de]*/ DecCtx_BinaryFunc(mpd_qand) /*[clinic input] @@ -7323,8 +7318,7 @@ _decimal.Context.logical_or = _decimal.Context.add Applies the logical operation 'or' between each operand's digits. -Both operands should have zero sign and exponent, and digits -either 0 or 1. +The operands must be both logical numbers. >>> ExtendedContext.logical_or(Decimal('0'), Decimal('0')) Decimal('0') @@ -7349,7 +7343,7 @@ either 0 or 1. static PyObject * _decimal_Context_logical_or_impl(PyObject *context, PyTypeObject *cls, PyObject *x, PyObject *y) -/*[clinic end generated code: output=eb38617e8d31bf12 input=380611292d885f9d]*/ +/*[clinic end generated code: output=eb38617e8d31bf12 input=47b45d296fb90846]*/ DecCtx_BinaryFunc(mpd_qor) /*[clinic input] @@ -7357,8 +7351,7 @@ _decimal.Context.logical_xor = _decimal.Context.add Applies the logical operation 'xor' between each operand's digits. -Both operands should have zero sign and exponent, and digits -either 0 or 1. +The operands must be both logical numbers. >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0')) Decimal('0') @@ -7383,7 +7376,7 @@ either 0 or 1. static PyObject * _decimal_Context_logical_xor_impl(PyObject *context, PyTypeObject *cls, PyObject *x, PyObject *y) -/*[clinic end generated code: output=23cd81fdcd865d5a input=a23b928a8d0f5df0]*/ +/*[clinic end generated code: output=23cd81fdcd865d5a input=fcaaf828c1d2d089]*/ DecCtx_BinaryFunc(mpd_qxor) /*[clinic input] diff --git a/Modules/_decimal/clinic/_decimal.c.h b/Modules/_decimal/clinic/_decimal.c.h index b89c9ed8179c96..b09200845d12e9 100644 --- a/Modules/_decimal/clinic/_decimal.c.h +++ b/Modules/_decimal/clinic/_decimal.c.h @@ -2746,7 +2746,7 @@ PyDoc_STRVAR(_decimal_Decimal_logical_invert__doc__, "\n" "Invert all its digits.\n" "\n" -"The self should have zero sign and exponent, and digits either 0 or 1."); +"The self must be logical number."); #define _DECIMAL_DECIMAL_LOGICAL_INVERT_METHODDEF \ {"logical_invert", _PyCFunction_CAST(_decimal_Decimal_logical_invert), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_logical_invert__doc__}, @@ -3340,8 +3340,7 @@ PyDoc_STRVAR(_decimal_Decimal_logical_and__doc__, "\n" "Applies an \'and\' operation between self and other\'s digits.\n" "\n" -"Both self and other should have zero sign and exponent,\n" -"and digits either 0 or 1."); +"Both self and other must be logical numbers."); #define _DECIMAL_DECIMAL_LOGICAL_AND_METHODDEF \ {"logical_and", _PyCFunction_CAST(_decimal_Decimal_logical_and), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_logical_and__doc__}, @@ -3409,8 +3408,7 @@ PyDoc_STRVAR(_decimal_Decimal_logical_or__doc__, "\n" "Applies an \'or\' operation between self and other\'s digits.\n" "\n" -"Both self and other should have zero sign and exponent,\n" -"and digits either 0 or 1."); +"Both self and other must be logical numbers."); #define _DECIMAL_DECIMAL_LOGICAL_OR_METHODDEF \ {"logical_or", _PyCFunction_CAST(_decimal_Decimal_logical_or), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_logical_or__doc__}, @@ -3478,8 +3476,7 @@ PyDoc_STRVAR(_decimal_Decimal_logical_xor__doc__, "\n" "Applies an \'xor\' operation between self and other\'s digits.\n" "\n" -"Both self and other should have zero sign and exponent,\n" -"and digits either 0 or 1."); +"Both self and other must be logical numbers."); #define _DECIMAL_DECIMAL_LOGICAL_XOR_METHODDEF \ {"logical_xor", _PyCFunction_CAST(_decimal_Decimal_logical_xor), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Decimal_logical_xor__doc__}, @@ -6248,8 +6245,7 @@ PyDoc_STRVAR(_decimal_Context_logical_invert__doc__, "\n" "Invert all the digits in the operand.\n" "\n" -"The operand should have zero sign and exponent, and digits\n" -"either 0 or 1.\n" +"The operand must be a logical number.\n" "\n" " >>> ExtendedContext.logical_invert(Decimal(\'0\'))\n" " Decimal(\'111111111\')\n" @@ -6583,8 +6579,7 @@ PyDoc_STRVAR(_decimal_Context_logical_and__doc__, "\n" "Applies the logical operation \'and\' between each operand\'s digits.\n" "\n" -"Both operands should have zero sign and exponent, and\n" -"digits either 0 or 1.\n" +"The operands must be both logical numbers.\n" "\n" " >>> ExtendedContext.logical_and(Decimal(\'0\'), Decimal(\'0\'))\n" " Decimal(\'0\')\n" @@ -6652,8 +6647,7 @@ PyDoc_STRVAR(_decimal_Context_logical_or__doc__, "\n" "Applies the logical operation \'or\' between each operand\'s digits.\n" "\n" -"Both operands should have zero sign and exponent, and digits\n" -"either 0 or 1.\n" +"The operands must be both logical numbers.\n" "\n" " >>> ExtendedContext.logical_or(Decimal(\'0\'), Decimal(\'0\'))\n" " Decimal(\'0\')\n" @@ -6721,8 +6715,7 @@ PyDoc_STRVAR(_decimal_Context_logical_xor__doc__, "\n" "Applies the logical operation \'xor\' between each operand\'s digits.\n" "\n" -"Both operands should have zero sign and exponent, and digits\n" -"either 0 or 1.\n" +"The operands must be both logical numbers.\n" "\n" " >>> ExtendedContext.logical_xor(Decimal(\'0\'), Decimal(\'0\'))\n" " Decimal(\'0\')\n" @@ -6987,4 +6980,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=772d05afebf1ce88 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b288181c82fdc9f1 input=a9049054013a1b77]*/