diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-02-25 15:57:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 15:57:58 (GMT) |
commit | 6a44f6eef3d0958d88882347190b3e2d1222c2e9 (patch) | |
tree | bb6474b1e094a672837c3333a081fa4d5d7638f2 /Include | |
parent | d90a141bb947b68601f8d1f37bc98f7b524f0e01 (diff) | |
download | cpython-6a44f6eef3d0958d88882347190b3e2d1222c2e9.zip cpython-6a44f6eef3d0958d88882347190b3e2d1222c2e9.tar.gz cpython-6a44f6eef3d0958d88882347190b3e2d1222c2e9.tar.bz2 |
bpo-36048: Use __index__() instead of __int__() for implicit conversion if available. (GH-11952)
Deprecate using the __int__() method in implicit conversions of Python
numbers to C integers.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/longobject.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Include/longobject.h b/Include/longobject.h index 82c06c9..b696f54 100644 --- a/Include/longobject.h +++ b/Include/longobject.h @@ -177,7 +177,17 @@ PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, nb_int slot is not available or the result of the call to nb_int returns something not of type int. */ -PyAPI_FUNC(PyLongObject *)_PyLong_FromNbInt(PyObject *); +PyAPI_FUNC(PyObject *) _PyLong_FromNbInt(PyObject *); + +/* Convert the given object to a PyLongObject using the nb_index or + nb_int slots, if available (the latter is deprecated). + Raise TypeError if either nb_index and nb_int slots are not + available or the result of the call to nb_index or nb_int + returns something not of type int. + Should be replaced with PyNumber_Index after the end of the + deprecation period. +*/ +PyAPI_FUNC(PyObject *) _PyLong_FromNbIndexOrNbInt(PyObject *); /* _PyLong_Format: Convert the long to a string object with given base, appending a base prefix of 0[box] if base is 2, 8 or 16. */ |