Skip to content

Commit 369e38e

Browse files
authored
[3.15] Fix inaccurate wording in multiple decimal module docstrings (GH-155688) (#160658)
1 parent 1a58a6a commit 369e38e

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

‎Lib/_pydecimal.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5158,8 +5158,8 @@ def number_class(self, a):
51585158
"""Returns an indication of the class of the operand.
51595159
51605160
The class is one of the following strings:
5161-
-sNaN
5162-
-NaN
5161+
sNaN
5162+
NaN
51635163
-Infinity
51645164
-Normal
51655165
-Subnormal
@@ -5668,8 +5668,9 @@ def to_integral_value(self, a):
56685668
When the operand has a negative exponent, the result is the same
56695669
as using the quantize() operation using the given operand as the
56705670
left-hand-operand, 1E+0 as the right-hand-operand, and the precision
5671-
of the operand as the precision setting, except that no flags will
5672-
be set. The rounding mode is taken from the context.
5671+
of the operand as the precision setting, except that the Inexact and
5672+
Rounded flags will not be set. The rounding mode is taken from the
5673+
context.
56735674
56745675
>>> ExtendedContext.to_integral_value(Decimal('2.1'))
56755676
Decimal('2')

‎Modules/_decimal/_decimal.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6749,7 +6749,7 @@ _decimal.Context.power
67496749
Compute a**b.
67506750
67516751
If 'a' is negative, then 'b' must be integral. The result will be
6752-
inexact unless 'a' is integral and the result is finite and can be
6752+
inexact unless 'b' is integral and the result is finite and can be
67536753
expressed exactly in 'precision' digits. In the Python version the
67546754
result is always correctly rounded, in the C version the result is
67556755
almost always correctly rounded.
@@ -6767,7 +6767,7 @@ restrictions hold:
67676767
static PyObject *
67686768
_decimal_Context_power_impl(PyObject *context, PyTypeObject *cls,
67696769
PyObject *base, PyObject *exp, PyObject *mod)
6770-
/*[clinic end generated code: output=d06d40c37cdd69dc input=178a254468ec189b]*/
6770+
/*[clinic end generated code: output=d06d40c37cdd69dc input=660210a6607ca4b0]*/
67716771
{
67726772
PyObject *a, *b, *c = NULL;
67736773
PyObject *result;
@@ -7027,13 +7027,19 @@ _decimal_Context_apply_impl(PyObject *context, PyTypeObject *cls,
70277027
/*[clinic input]
70287028
_decimal.Context.canonical = _decimal.Context.is_normal
70297029
7030-
Return a new instance of x.
7030+
Returns the same Decimal object.
7031+
7032+
As we do not have different encodings for the same number, the
7033+
received object already is in its canonical form.
7034+
7035+
>>> ExtendedContext.canonical(Decimal('2.50'))
7036+
Decimal('2.50')
70317037
[clinic start generated code]*/
70327038

70337039
static PyObject *
70347040
_decimal_Context_canonical_impl(PyObject *context, PyTypeObject *cls,
70357041
PyObject *x)
7036-
/*[clinic end generated code: output=f213e433e2032e5e input=025ecb106ac15bff]*/
7042+
/*[clinic end generated code: output=f213e433e2032e5e input=d9f19ee3e7ed9433]*/
70377043
{
70387044
decimal_state *state = PyType_GetModuleState(cls);
70397045
if (!PyDec_Check(state, x)) {

‎Modules/_decimal/clinic/_decimal.c.h‎

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)