diff --git a/Doc/library/math.rst b/Doc/library/math.rst index 145bac4966e18c..cff6961c186059 100644 --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -33,7 +33,7 @@ Number-theoretic and representation functions Return the ceiling of *x*, the smallest integer greater than or equal to *x*. If *x* is not a float, delegates to ``x.__ceil__()``, which should return an - :class:`~numbers.Integral` value. + :class:`~numbers.Integer` value. .. function:: comb(n, k) @@ -79,7 +79,7 @@ Number-theoretic and representation functions Return the floor of *x*, the largest integer less than or equal to *x*. If *x* is not a float, delegates to ``x.__floor__()``, which should return an - :class:`~numbers.Integral` value. + :class:`~numbers.Integer` value. .. function:: fmod(x, y) @@ -299,7 +299,7 @@ Number-theoretic and representation functions .. function:: trunc(x) Return the :class:`~numbers.Real` value *x* truncated to an - :class:`~numbers.Integral` (usually an integer). Delegates to + :class:`~numbers.Integer` (usually an integer). Delegates to :meth:`x.__trunc__() `. .. function:: ulp(x) diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst index 1b594952ead724..cd1804b4c29890 100644 --- a/Doc/library/numbers.rst +++ b/Doc/library/numbers.rst @@ -2,7 +2,7 @@ ================================================ .. module:: numbers - :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.). + :synopsis: Numeric abstract base classes (Complex, Real, Integer, etc.). **Source code:** :source:`Lib/numbers.py` @@ -72,13 +72,19 @@ The numeric tower Abstract. -.. class:: Integral +.. class:: Integer Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides defaults for :func:`float`, :attr:`~Rational.numerator`, and :attr:`~Rational.denominator`. Adds abstract methods for ``**`` and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``. +.. class:: Integral + + Alias for :class:`Integer`. + + .. deprecated:: 3.10 + Notes for type implementors --------------------------- @@ -121,13 +127,13 @@ Implementing the arithmetic operations We want to implement the arithmetic operations so that mixed-mode operations either call an implementation whose author knew about the types of both arguments, or convert both to the nearest built in type -and do the operation there. For subtypes of :class:`Integral`, this +and do the operation there. For subtypes of :class:`Integer`, this means that :meth:`__add__` and :meth:`__radd__` should be defined as:: - class MyIntegral(Integral): + class MyInteger(Integer): def __add__(self, other): - if isinstance(other, MyIntegral): + if isinstance(other, MyInteger): return do_my_adding_stuff(self, other) elif isinstance(other, OtherTypeIKnowAbout): return do_my_other_adding_stuff(self, other) @@ -135,11 +141,11 @@ means that :meth:`__add__` and :meth:`__radd__` should be defined as:: return NotImplemented def __radd__(self, other): - if isinstance(other, MyIntegral): + if isinstance(other, MyInteger): return do_my_adding_stuff(other, self) elif isinstance(other, OtherTypeIKnowAbout): return do_my_other_adding_stuff(other, self) - elif isinstance(other, Integral): + elif isinstance(other, Integer): return int(other) + int(self) elif isinstance(other, Real): return float(other) + float(self) @@ -151,7 +157,7 @@ means that :meth:`__add__` and :meth:`__radd__` should be defined as:: There are 5 different cases for a mixed-type operation on subclasses of :class:`Complex`. I'll refer to all of the above code that doesn't -refer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as +refer to ``MyInteger`` and ``OtherTypeIKnowAbout`` as "boilerplate". ``a`` will be an instance of ``A``, which is a subtype of :class:`Complex` (``a : A <: Complex``), and ``b : B <: Complex``. I'll consider ``a + b``: diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index b83d0d87f587fc..c8e67cb273b3fd 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -362,17 +362,17 @@ the following operations: +--------------------+---------------------------------------------+ | Operation | Result | +====================+=============================================+ -| :func:`math.trunc(\| *x* truncated to :class:`~numbers.Integral` | +| :func:`math.trunc(\| *x* truncated to :class:`~numbers.Integer` | | x) ` | | +--------------------+---------------------------------------------+ | :func:`round(x[, | *x* rounded to *n* digits, | | n]) ` | rounding half to even. If *n* is | | | omitted, it defaults to 0. | +--------------------+---------------------------------------------+ -| :func:`math.floor(\| the greatest :class:`~numbers.Integral` | +| :func:`math.floor(\| the greatest :class:`~numbers.Integer` | | x) ` | <= *x* | +--------------------+---------------------------------------------+ -| :func:`math.ceil(x)| the least :class:`~numbers.Integral` >= *x* | +| :func:`math.ceil(x)| the least :class:`~numbers.Integer` >= *x* | | ` | | +--------------------+---------------------------------------------+ @@ -449,7 +449,7 @@ Notes: Additional Methods on Integer Types ----------------------------------- -The int type implements the :class:`numbers.Integral` :term:`abstract base +The int type implements the :class:`numbers.Integer` :term:`abstract base class`. In addition, it provides a few more methods: .. method:: int.bit_length() diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 1697330cb9153b..3127b7f45de326 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -208,7 +208,7 @@ Ellipsis Python distinguishes between integers, floating point numbers, and complex numbers: - :class:`numbers.Integral` + :class:`numbers.Integer` .. index:: object: integer These represent elements from the mathematical set of integers (positive and @@ -2495,7 +2495,7 @@ left undefined. Called to implement the built-in function :func:`round` and :mod:`math` functions :func:`~math.trunc`, :func:`~math.floor` and :func:`~math.ceil`. Unless *ndigits* is passed to :meth:`!__round__` all these methods should - return the value of the object truncated to an :class:`~numbers.Integral` + return the value of the object truncated to an :class:`~numbers.Integer` (typically an :class:`int`). If :meth:`__int__` is not defined then the built-in function :func:`int` diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index b6174a19a178b6..5d88be69bbafef 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -1415,7 +1415,7 @@ converted to floats. Python 2.6 adds a simple rational-number class, :class:`Fraction` instead of :class:`Rational` to avoid a name clash with :class:`numbers.Rational`.) -:class:`Integral` numbers derive from :class:`Rational`, and +``Integral`` numbers derive from :class:`Rational`, and can be shifted left and right with ``<<`` and ``>>``, combined using bitwise operations such as ``&`` and ``|``, and can be used as array indexes and slice boundaries. @@ -1424,7 +1424,7 @@ In Python 3.0, the PEP slightly redefines the existing builtins :func:`round`, :func:`math.floor`, :func:`math.ceil`, and adds a new one, :func:`math.trunc`, that's been backported to Python 2.6. :func:`math.trunc` rounds toward zero, returning the closest -:class:`Integral` that's between the function's argument and zero. +``Integral`` that's between the function's argument and zero. .. seealso:: @@ -1445,7 +1445,7 @@ values as a numerator and denominator forming a fraction, and can exactly represent numbers such as ``2/3`` that floating-point numbers can only approximate. -The :class:`Fraction` constructor takes two :class:`Integral` values +The :class:`Fraction` constructor takes two ``Integral`` values that will be the numerator and denominator of the resulting fraction. :: >>> from fractions import Fraction @@ -2111,7 +2111,7 @@ changes, or look through the Subversion logs for all the details. (base *e*). * :func:`trunc` rounds a number toward zero, returning the closest - :class:`Integral` that's between the function's argument and zero. + ``Integral`` that's between the function's argument and zero. Added as part of the backport of `PEP 3141's type hierarchy for numbers <#pep-3141>`__. diff --git a/Lib/fractions.py b/Lib/fractions.py index 96047beb4546a5..261bc06041fd27 100644 --- a/Lib/fractions.py +++ b/Lib/fractions.py @@ -171,7 +171,7 @@ def from_float(cls, f): Beware that Fraction.from_float(0.3) != Fraction(3, 10). """ - if isinstance(f, numbers.Integral): + if isinstance(f, numbers.Integer): return cls(f) elif not isinstance(f, float): raise TypeError("%s.from_float() only takes floats, not %r (%s)" % @@ -182,7 +182,7 @@ def from_float(cls, f): def from_decimal(cls, dec): """Converts a finite Decimal instance to a rational number, exactly.""" from decimal import Decimal - if isinstance(dec, numbers.Integral): + if isinstance(dec, numbers.Integer): dec = Decimal(int(dec)) elif not isinstance(dec, Decimal): raise TypeError( diff --git a/Lib/numbers.py b/Lib/numbers.py index ed815ef41ebe12..cedaf246c11520 100644 --- a/Lib/numbers.py +++ b/Lib/numbers.py @@ -7,7 +7,7 @@ from abc import ABCMeta, abstractmethod -__all__ = ["Number", "Complex", "Real", "Rational", "Integral"] +__all__ = ["Number", "Complex", "Real", "Rational", "Integer", "Integral"] class Number(metaclass=ABCMeta): """All numbers inherit from this class. @@ -164,12 +164,12 @@ def __float__(self): @abstractmethod def __trunc__(self): - """trunc(self): Truncates self to an Integral. + """trunc(self): Truncates self to an Integer. - Returns an Integral i such that: + Returns an Integer i such that: * i>0 iff self>0; * abs(i) <= abs(self); - * for any Integral j satisfying the first two conditions, + * for any Integer j satisfying the first two conditions, abs(i) >= abs(j) [i.e. i has "maximal" abs among those]. i.e. "truncate towards 0". """ @@ -177,19 +177,19 @@ def __trunc__(self): @abstractmethod def __floor__(self): - """Finds the greatest Integral <= self.""" + """Finds the greatest Integer <= self.""" raise NotImplementedError @abstractmethod def __ceil__(self): - """Finds the least Integral >= self.""" + """Finds the least Integer >= self.""" raise NotImplementedError @abstractmethod def __round__(self, ndigits=None): """Rounds self to ndigits decimal places, defaulting to 0. - If ndigits is omitted or None, returns an Integral, otherwise + If ndigits is omitted or None, returns an Integer, otherwise returns a Real. Rounds half toward even. """ raise NotImplementedError @@ -291,8 +291,8 @@ def __float__(self): return self.numerator / self.denominator -class Integral(Rational): - """Integral adds a conversion to int and the bit-string operations.""" +class Integer(Rational): + """Integer adds a conversion to int and the bit-string operations.""" __slots__ = () @@ -311,7 +311,7 @@ def __pow__(self, exponent, modulus=None): Accept the modulus argument if you want to support the 3-argument version of pow(). Raise a TypeError if exponent < 0 - or any argument isn't Integral. Otherwise, just implement the + or any argument isn't Integer. Otherwise, just implement the 2-argument version described in Complex. """ raise NotImplementedError @@ -386,4 +386,7 @@ def denominator(self): """Integers have a denominator of 1.""" return 1 -Integral.register(int) +Integer.register(int) + +# Compatibility alias. +Integral = Integer diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py index 83e1a975ec78b2..f4081326c337f7 100644 --- a/Lib/pydoc_data/topics.py +++ b/Lib/pydoc_data/topics.py @@ -7870,7 +7870,7 @@ '*ndigits* is\n' ' passed to "__round__()" all these methods should return ' 'the value\n' - ' of the object truncated to an "Integral" (typically an ' + ' of the object truncated to an "Integer" (typically an ' '"int").\n' '\n' ' If "__int__()" is not defined then the built-in function ' @@ -10592,7 +10592,7 @@ '*ndigits* is\n' ' passed to "__round__()" all these methods should return ' 'the value\n' - ' of the object truncated to an "Integral" (typically an ' + ' of the object truncated to an "Integer" (typically an ' '"int").\n' '\n' ' If "__int__()" is not defined then the built-in function ' @@ -12316,7 +12316,7 @@ 'and\n' ' complex numbers:\n' '\n' - ' "numbers.Integral"\n' + ' "numbers.Integer"\n' ' These represent elements from the mathematical set of ' 'integers\n' ' (positive and negative).\n' diff --git a/Lib/statistics.py b/Lib/statistics.py index 673a162b3a79fc..b5dfa3f8df1df9 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -258,7 +258,7 @@ def _exact_ratio(x): if type(x) is float or type(x) is Decimal: return x.as_integer_ratio() try: - # x may be an int, Fraction, or Integral ABC. + # x may be an int, Fraction, or Integer ABC. return (x.numerator, x.denominator) except AttributeError: try: diff --git a/Lib/test/test_abstract_numbers.py b/Lib/test/test_abstract_numbers.py index 2e06f0d16fdd05..88b51d3b78cb15 100644 --- a/Lib/test/test_abstract_numbers.py +++ b/Lib/test/test_abstract_numbers.py @@ -3,10 +3,11 @@ import math import operator import unittest -from numbers import Complex, Real, Rational, Integral +from numbers import Complex, Real, Rational, Integer, Integral class TestNumbers(unittest.TestCase): def test_int(self): + self.assertTrue(issubclass(int, Integer)) self.assertTrue(issubclass(int, Integral)) self.assertTrue(issubclass(int, Complex)) diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py index d6be64e7c18a08..b2293afa8a9de5 100644 --- a/Lib/test/test_int.py +++ b/Lib/test/test_int.py @@ -396,20 +396,20 @@ def __trunc__(self): return Intable() self.assertEqual(int(TruncReturnsNonInt()), 42) - class NonIntegral(trunc_result_base): + class NonInteger(trunc_result_base): def __trunc__(self): # Check that we avoid infinite recursion. - return NonIntegral() + return NonInteger() - class TruncReturnsNonIntegral(base): + class TruncReturnsNonInteger(base): def __trunc__(self): - return NonIntegral() + return NonInteger() try: - int(TruncReturnsNonIntegral()) + int(TruncReturnsNonInteger()) except TypeError as e: self.assertEqual(str(e), - "__trunc__ returned non-Integral" - " (type NonIntegral)") + "__trunc__ returned non-Integer" + " (type NonInteger)") else: self.fail("Failed to raise TypeError with %s" % ((base, trunc_result_base),)) diff --git a/Misc/NEWS.d/3.10.0a1.rst b/Misc/NEWS.d/3.10.0a1.rst index 044bd20594cc37..9f67c73d865336 100644 --- a/Misc/NEWS.d/3.10.0a1.rst +++ b/Misc/NEWS.d/3.10.0a1.rst @@ -2566,7 +2566,7 @@ with other number types. .. section: Library The x.is_integer() method is incorporated into the abstract types of the -numeric tower, Real, Rational and Integral, with appropriate default +numeric tower, Real, Rational and Integer, with appropriate default implementations. .. diff --git a/Misc/NEWS.d/next/Library/2021-04-22-11-01-25.bpo-32891.fQqX89.rst b/Misc/NEWS.d/next/Library/2021-04-22-11-01-25.bpo-32891.fQqX89.rst new file mode 100644 index 00000000000000..fb7ceae96a30e3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-04-22-11-01-25.bpo-32891.fQqX89.rst @@ -0,0 +1,2 @@ +Added :class:`~numbers.Integer` as a synonym for old :class:`~numbers.Integral`, +which is deprecated. Contributed by Sergey B Kirpichev. diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h index 65f3dd4f520aeb..1d6d3d13e22a39 100644 --- a/Modules/clinic/mathmodule.c.h +++ b/Modules/clinic/mathmodule.c.h @@ -6,7 +6,7 @@ PyDoc_STRVAR(math_ceil__doc__, "ceil($module, x, /)\n" "--\n" "\n" -"Return the ceiling of x as an Integral.\n" +"Return the ceiling of x as an Integer.\n" "\n" "This is the smallest integer >= x."); @@ -17,7 +17,7 @@ PyDoc_STRVAR(math_floor__doc__, "floor($module, x, /)\n" "--\n" "\n" -"Return the floor of x as an Integral.\n" +"Return the floor of x as an Integer.\n" "\n" "This is the largest integer <= x."); @@ -59,7 +59,7 @@ PyDoc_STRVAR(math_trunc__doc__, "trunc($module, x, /)\n" "--\n" "\n" -"Truncates the Real x to the nearest Integral toward 0.\n" +"Truncates the Real x to the nearest Integer toward 0.\n" "\n" "Uses the __trunc__ magic method."); @@ -865,4 +865,4 @@ math_ulp(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=1eae2b3ef19568fa input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d88ee9340bf8ef89 input=a9049054013a1b77]*/ diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index d0dd12d25966a1..80fe9905679930 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -1185,14 +1185,14 @@ math.ceil x as number: object / -Return the ceiling of x as an Integral. +Return the ceiling of x as an Integer. This is the smallest integer >= x. [clinic start generated code]*/ static PyObject * math_ceil(PyObject *module, PyObject *number) -/*[clinic end generated code: output=6c3b8a78bc201c67 input=2725352806399cab]*/ +/*[clinic end generated code: output=6c3b8a78bc201c67 input=241105afc3ed79f0]*/ { _Py_IDENTIFIER(__ceil__); @@ -1248,14 +1248,14 @@ math.floor x as number: object / -Return the floor of x as an Integral. +Return the floor of x as an Integer. This is the largest integer <= x. [clinic start generated code]*/ static PyObject * math_floor(PyObject *module, PyObject *number) -/*[clinic end generated code: output=c6a65c4884884b8a input=63af6b5d7ebcc3d6]*/ +/*[clinic end generated code: output=c6a65c4884884b8a input=51997fb61226178b]*/ { double x; @@ -2094,14 +2094,14 @@ math.trunc x: object / -Truncates the Real x to the nearest Integral toward 0. +Truncates the Real x to the nearest Integer toward 0. Uses the __trunc__ magic method. [clinic start generated code]*/ static PyObject * math_trunc(PyObject *module, PyObject *x) -/*[clinic end generated code: output=34b9697b707e1031 input=2168b34e0a09134d]*/ +/*[clinic end generated code: output=34b9697b707e1031 input=474e3f3f5ecdf91d]*/ { _Py_IDENTIFIER(__trunc__); PyObject *trunc, *result; diff --git a/Objects/abstract.c b/Objects/abstract.c index fcfe2dbe483f4f..cee066b33c55bf 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1506,12 +1506,12 @@ PyNumber_Long(PyObject *o) Py_SETREF(result, _PyLong_Copy((PyLongObject *)result)); return result; } - /* __trunc__ is specified to return an Integral type, + /* __trunc__ is specified to return an Integer type, but int() needs to return an int. */ if (!PyIndex_Check(result)) { PyErr_Format( PyExc_TypeError, - "__trunc__ returned non-Integral (type %.200s)", + "__trunc__ returned non-Integer (type %.200s)", Py_TYPE(result)->tp_name); Py_DECREF(result); return NULL; diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h index 5643f0e3ac6501..d0ded463fb80d4 100644 --- a/Objects/clinic/floatobject.c.h +++ b/Objects/clinic/floatobject.c.h @@ -24,7 +24,7 @@ PyDoc_STRVAR(float___trunc____doc__, "__trunc__($self, /)\n" "--\n" "\n" -"Return the Integral closest to x between 0 and x."); +"Return the Integer closest to x between 0 and x."); #define FLOAT___TRUNC___METHODDEF \ {"__trunc__", (PyCFunction)float___trunc__, METH_NOARGS, float___trunc____doc__}, @@ -42,7 +42,7 @@ PyDoc_STRVAR(float___floor____doc__, "__floor__($self, /)\n" "--\n" "\n" -"Return the floor as an Integral."); +"Return the floor as an Integer."); #define FLOAT___FLOOR___METHODDEF \ {"__floor__", (PyCFunction)float___floor__, METH_NOARGS, float___floor____doc__}, @@ -60,7 +60,7 @@ PyDoc_STRVAR(float___ceil____doc__, "__ceil__($self, /)\n" "--\n" "\n" -"Return the ceiling as an Integral."); +"Return the ceiling as an Integer."); #define FLOAT___CEIL___METHODDEF \ {"__ceil__", (PyCFunction)float___ceil__, METH_NOARGS, float___ceil____doc__}, @@ -78,7 +78,7 @@ PyDoc_STRVAR(float___round____doc__, "__round__($self, ndigits=None, /)\n" "--\n" "\n" -"Return the Integral closest to x, rounding half toward even.\n" +"Return the Integer closest to x, rounding half toward even.\n" "\n" "When an argument is passed, work like built-in round(x, ndigits)."); @@ -387,4 +387,4 @@ float___format__(PyObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=bb079c3e130e4ce6 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=26d7f82beddb70f3 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h index 4bd47b116f883c..22774fb8614313 100644 --- a/Objects/clinic/longobject.c.h +++ b/Objects/clinic/longobject.c.h @@ -91,7 +91,7 @@ PyDoc_STRVAR(int___round____doc__, "__round__($self, ndigits=, /)\n" "--\n" "\n" -"Rounding an Integral returns itself.\n" +"Rounding an Integer returns itself.\n" "\n" "Rounding with an ndigits argument also returns an integer."); @@ -367,4 +367,4 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb exit: return return_value; } -/*[clinic end generated code: output=ea18e51af5b53591 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2f8dc0df78ffe228 input=a9049054013a1b77]*/ diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 7e78132c01ca27..b7993ea2cc4890 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -875,12 +875,12 @@ float_is_integer_impl(PyObject *self) /*[clinic input] float.__trunc__ -Return the Integral closest to x between 0 and x. +Return the Integer closest to x between 0 and x. [clinic start generated code]*/ static PyObject * float___trunc___impl(PyObject *self) -/*[clinic end generated code: output=dd3e289dd4c6b538 input=591b9ba0d650fdff]*/ +/*[clinic end generated code: output=dd3e289dd4c6b538 input=eefcc6ff76192e0d]*/ { return PyLong_FromDouble(PyFloat_AS_DOUBLE(self)); } @@ -888,12 +888,12 @@ float___trunc___impl(PyObject *self) /*[clinic input] float.__floor__ -Return the floor as an Integral. +Return the floor as an Integer. [clinic start generated code]*/ static PyObject * float___floor___impl(PyObject *self) -/*[clinic end generated code: output=e0551dbaea8c01d1 input=77bb13eb12e268df]*/ +/*[clinic end generated code: output=e0551dbaea8c01d1 input=2a296a9cff7dc684]*/ { double x = PyFloat_AS_DOUBLE(self); return PyLong_FromDouble(floor(x)); @@ -902,12 +902,12 @@ float___floor___impl(PyObject *self) /*[clinic input] float.__ceil__ -Return the ceiling as an Integral. +Return the ceiling as an Integer. [clinic start generated code]*/ static PyObject * float___ceil___impl(PyObject *self) -/*[clinic end generated code: output=a2fd8858f73736f9 input=79e41ae94aa0a516]*/ +/*[clinic end generated code: output=a2fd8858f73736f9 input=c41118a42bf6f83c]*/ { double x = PyFloat_AS_DOUBLE(self); return PyLong_FromDouble(ceil(x)); @@ -1035,14 +1035,14 @@ float.__round__ ndigits as o_ndigits: object = None / -Return the Integral closest to x, rounding half toward even. +Return the Integer closest to x, rounding half toward even. When an argument is passed, work like built-in round(x, ndigits). [clinic start generated code]*/ static PyObject * float___round___impl(PyObject *self, PyObject *o_ndigits) -/*[clinic end generated code: output=374c36aaa0f13980 input=fc0fe25924fbc9ed]*/ +/*[clinic end generated code: output=374c36aaa0f13980 input=7121091402918db5]*/ { double x, rounded; Py_ssize_t ndigits; diff --git a/Objects/longobject.c b/Objects/longobject.c index e1c1191e648dae..1711493e344d47 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5153,14 +5153,14 @@ int.__round__ ndigits as o_ndigits: object = NULL / -Rounding an Integral returns itself. +Rounding an Integer returns itself. Rounding with an ndigits argument also returns an integer. [clinic start generated code]*/ static PyObject * int___round___impl(PyObject *self, PyObject *o_ndigits) -/*[clinic end generated code: output=954fda6b18875998 input=1614cf23ec9e18c3]*/ +/*[clinic end generated code: output=954fda6b18875998 input=3ee1ce59e9f0235c]*/ { PyObject *temp, *result, *ndigits; @@ -5533,11 +5533,11 @@ static PyMethodDef long_methods[] = { INT_FROM_BYTES_METHODDEF INT_AS_INTEGER_RATIO_METHODDEF {"__trunc__", long_long_meth, METH_NOARGS, - "Truncating an Integral returns itself."}, + "Truncating an Integer returns itself."}, {"__floor__", long_long_meth, METH_NOARGS, - "Flooring an Integral returns itself."}, + "Flooring an Integer returns itself."}, {"__ceil__", long_long_meth, METH_NOARGS, - "Ceiling of an Integral returns itself."}, + "Ceiling of an Integer returns itself."}, INT___ROUND___METHODDEF INT___GETNEWARGS___METHODDEF INT___FORMAT___METHODDEF