Skip to content

Commit e03def8

Browse files
authored
Fix inaccurate wording in multiple decimal module docstrings (#155688)
1 parent 02c5d55 commit e03def8

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
@@ -5172,8 +5172,8 @@ def number_class(self, a):
51725172
"""Returns an indication of the class of the operand.
51735173
51745174
The class is one of the following strings:
5175-
-sNaN
5176-
-NaN
5175+
sNaN
5176+
NaN
51775177
-Infinity
51785178
-Normal
51795179
-Subnormal
@@ -5682,8 +5682,9 @@ def to_integral_value(self, a):
56825682
When the operand has a negative exponent, the result is the same
56835683
as using the quantize() operation using the given operand as the
56845684
left-hand-operand, 1E+0 as the right-hand-operand, and the precision
5685-
of the operand as the precision setting, except that no flags will
5686-
be set. The rounding mode is taken from the context.
5685+
of the operand as the precision setting, except that the Inexact and
5686+
Rounded flags will not be set. The rounding mode is taken from the
5687+
context.
56875688
56885689
>>> ExtendedContext.to_integral_value(Decimal('2.1'))
56895690
Decimal('2')

‎Modules/_decimal/_decimal.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6789,7 +6789,7 @@ _decimal.Context.power
67896789
Compute a**b.
67906790
67916791
If 'a' is negative, then 'b' must be integral. The result will be
6792-
inexact unless 'a' is integral and the result is finite and can be
6792+
inexact unless 'b' is integral and the result is finite and can be
67936793
expressed exactly in 'precision' digits. In the Python version the
67946794
result is always correctly rounded, in the C version the result is
67956795
almost always correctly rounded.
@@ -6807,7 +6807,7 @@ restrictions hold:
68076807
static PyObject *
68086808
_decimal_Context_power_impl(PyObject *context, PyTypeObject *cls,
68096809
PyObject *base, PyObject *exp, PyObject *mod)
6810-
/*[clinic end generated code: output=d06d40c37cdd69dc input=178a254468ec189b]*/
6810+
/*[clinic end generated code: output=d06d40c37cdd69dc input=660210a6607ca4b0]*/
68116811
{
68126812
PyObject *a, *b, *c = NULL;
68136813
PyObject *result;
@@ -7067,13 +7067,19 @@ _decimal_Context_apply_impl(PyObject *context, PyTypeObject *cls,
70677067
/*[clinic input]
70687068
_decimal.Context.canonical = _decimal.Context.is_normal
70697069
7070-
Return a new instance of x.
7070+
Returns the same Decimal object.
7071+
7072+
As we do not have different encodings for the same number, the
7073+
received object already is in its canonical form.
7074+
7075+
>>> ExtendedContext.canonical(Decimal('2.50'))
7076+
Decimal('2.50')
70717077
[clinic start generated code]*/
70727078

70737079
static PyObject *
70747080
_decimal_Context_canonical_impl(PyObject *context, PyTypeObject *cls,
70757081
PyObject *x)
7076-
/*[clinic end generated code: output=f213e433e2032e5e input=025ecb106ac15bff]*/
7082+
/*[clinic end generated code: output=f213e433e2032e5e input=d9f19ee3e7ed9433]*/
70777083
{
70787084
decimal_state *state = PyType_GetModuleState(cls);
70797085
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)