[issue43101] Add deprecation of float limits for resource to documentation

Serhiy Storchaka report at bugs.python.org
Mon Feb 8 12:41:16 EST 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

This change was indirectly documented in What's New for 3.8 (deprecation) https://docs.python.org/3.8/whatsnew/3.8.html#build-and-c-api-changes:

"""
Functions that convert Python number to C integer like PyLong_AsLong() and argument parsing functions like PyArg_ParseTuple() with integer converting format units like 'i' will now use the __index__() special method instead of __int__(), if available. The deprecation warning will be emitted for objects with the __int__() method but without the __index__() method (like Decimal and Fraction). PyNumber_Check() will now return 1 for objects implementing __index__(). PyNumber_Long(), PyNumber_Float() and PyFloat_AsDouble() also now use the __index__() method if available.
"""

and for 3.10 (removing) https://docs.python.org/3.10/whatsnew/3.10.html#other-language-changes:

"""
Builtin and extension functions that take integer arguments no longer accept Decimals, Fractions and other objects that can be converted to integers only with a loss (e.g. that have the __int__() method but do not have the __index__() method).
"""

It was impractical to document it for every affected function, because there may be many tens of such functions in the stdlib, and it is difficult to find all functions which directly or indirectly use PyLong_AsLong() and similar C API. In any case accepting non-integer numbers was not intentional.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43101>
_______________________________________


More information about the Python-bugs-list mailing list