Skip to content

Commit 1e95dbb

Browse files
committed
Fix inaccurate wording in multiple decimal module docstrings
1 parent 1b5a6f7 commit 1e95dbb

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
@@ -6736,7 +6736,7 @@ _decimal.Context.power
67366736
Compute a**b.
67376737
67386738
If 'a' is negative, then 'b' must be integral. The result will be
6739-
inexact unless 'a' is integral and the result is finite and can be
6739+
inexact unless 'b' is integral and the result is finite and can be
67406740
expressed exactly in 'precision' digits. In the Python version the
67416741
result is always correctly rounded, in the C version the result is
67426742
almost always correctly rounded.
@@ -6754,7 +6754,7 @@ restrictions hold:
67546754
static PyObject *
67556755
_decimal_Context_power_impl(PyObject *context, PyTypeObject *cls,
67566756
PyObject *base, PyObject *exp, PyObject *mod)
6757-
/*[clinic end generated code: output=d06d40c37cdd69dc input=178a254468ec189b]*/
6757+
/*[clinic end generated code: output=d06d40c37cdd69dc input=660210a6607ca4b0]*/
67586758
{
67596759
PyObject *a, *b, *c = NULL;
67606760
PyObject *result;
@@ -7014,13 +7014,19 @@ _decimal_Context_apply_impl(PyObject *context, PyTypeObject *cls,
70147014
/*[clinic input]
70157015
_decimal.Context.canonical = _decimal.Context.is_normal
70167016
7017-
Return a new instance of x.
7017+
Returns the same Decimal object.
7018+
7019+
As we do not have different encodings for the same number, the
7020+
received object already is in its canonical form.
7021+
7022+
>>> ExtendedContext.canonical(Decimal('2.50'))
7023+
Decimal('2.50')
70187024
[clinic start generated code]*/
70197025

70207026
static PyObject *
70217027
_decimal_Context_canonical_impl(PyObject *context, PyTypeObject *cls,
70227028
PyObject *x)
7023-
/*[clinic end generated code: output=f213e433e2032e5e input=025ecb106ac15bff]*/
7029+
/*[clinic end generated code: output=f213e433e2032e5e input=d9f19ee3e7ed9433]*/
70247030
{
70257031
decimal_state *state = PyType_GetModuleState(cls);
70267032
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)