Skip to content

Commit e7eab7d

Browse files
committed
Fix inaccurate wording in multiple decimal module docstrings
1 parent 2473e7a commit e7eab7d

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎Lib/_pydecimal.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5155,8 +5155,8 @@ def number_class(self, a):
51555155
"""Returns an indication of the class of the operand.
51565156
51575157
The class is one of the following strings:
5158-
-sNaN
5159-
-NaN
5158+
sNaN
5159+
NaN
51605160
-Infinity
51615161
-Normal
51625162
-Subnormal
@@ -5665,8 +5665,9 @@ def to_integral_value(self, a):
56655665
When the operand has a negative exponent, the result is the same
56665666
as using the quantize() operation using the given operand as the
56675667
left-hand-operand, 1E+0 as the right-hand-operand, and the precision
5668-
of the operand as the precision setting, except that no flags will
5669-
be set. The rounding mode is taken from the context.
5668+
of the operand as the precision setting, except that the Inexact and
5669+
Rounded flags will not be set. The rounding mode is taken from the
5670+
context.
56705671
56715672
>>> ExtendedContext.to_integral_value(Decimal('2.1'))
56725673
Decimal('2')

‎Modules/_decimal/docstrings.h‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,13 @@ Return the sum of x and y.\n\
586586

587587
PyDoc_STRVAR(doc_ctx_canonical,
588588
"canonical($self, x, /)\n--\n\n\
589-
Return a new instance of x.\n\
589+
Returns the same Decimal object.\n\
590+
\n\
591+
As we do not have different encodings for the same number, the\n\
592+
received object already is in its canonical form.\n\
593+
\n\
594+
>>> ExtendedContext.canonical(Decimal('2.50'))\n\
595+
Decimal('2.50')\n\
590596
\n");
591597

592598
PyDoc_STRVAR(doc_ctx_compare,
@@ -867,7 +873,7 @@ the context to the result.\n\
867873
PyDoc_STRVAR(doc_ctx_power,
868874
"power($self, /, a, b, modulo=None)\n--\n\n\
869875
Compute a**b. If 'a' is negative, then 'b' must be integral. The result\n\
870-
will be inexact unless 'a' is integral and the result is finite and can\n\
876+
will be inexact unless 'b' is integral and the result is finite and can\n\
871877
be expressed exactly in 'precision' digits. In the Python version the\n\
872878
result is always correctly rounded, in the C version the result is almost\n\
873879
always correctly rounded.\n\

0 commit comments

Comments
 (0)