Author serhiy.storchaka
Recipients mark.dickinson, nafur, serhiy.storchaka
Date 2021-02-08.17:41:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612806076.43.0.991791557306.issue43101@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-02-08 17:41:16serhiy.storchakasetrecipients: + serhiy.storchaka, mark.dickinson, nafur
2021-02-08 17:41:16serhiy.storchakasetmessageid: <1612806076.43.0.991791557306.issue43101@roundup.psfhosted.org>
2021-02-08 17:41:16serhiy.storchakalinkissue43101 messages
2021-02-08 17:41:16serhiy.storchakacreate