bpo-40792: Make the result of PyNumber_Index() always having exact type int. (GH-20443)
Previously, the result could have been an instance of a subclass of int.
Also revert bpo-26202 and make attributes start, stop and step of the range
object having exact type int.
Add private function _PyNumber_Index() which preserves the old behavior
of PyNumber_Index() for performance to use it in the conversion functions
like PyLong_AsLong().
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 25d9814..8d64540 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -455,7 +455,7 @@
if (PyNumber_Check(v)) {
/* make sure number is a type of integer for o, x, and X */
if (type == 'o' || type == 'x' || type == 'X')
- iobj = PyNumber_Index(v);
+ iobj = _PyNumber_Index(v);
else
iobj = PyNumber_Long(v);
if (iobj == NULL) {