summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-08-24 21:55:30 (GMT)
committerGitHub <noreply@github.com>2023-08-24 21:55:30 (GMT)
commitbe436e08b8bd9fcd2202d6ce4d924bba7551e96f (patch)
treedf142099ae50383af0e76ed09f5b4d8d1cc15d3e /Include
parentfeb9a49c9c09d08cb8c24cb74d90a218de6af244 (diff)
downloadcpython-be436e08b8bd9fcd2202d6ce4d924bba7551e96f.zip
cpython-be436e08b8bd9fcd2202d6ce4d924bba7551e96f.tar.gz
cpython-be436e08b8bd9fcd2202d6ce4d924bba7551e96f.tar.bz2
gh-108444: Add PyLong_AsInt() public function (#108445)
* Rename _PyLong_AsInt() to PyLong_AsInt(). * Add documentation. * Add test. * For now, keep _PyLong_AsInt() as an alias to PyLong_AsInt().
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/longobject.h3
-rw-r--r--Include/longobject.h6
2 files changed, 8 insertions, 1 deletions
diff --git a/Include/cpython/longobject.h b/Include/cpython/longobject.h
index c581f51..c96f351 100644
--- a/Include/cpython/longobject.h
+++ b/Include/cpython/longobject.h
@@ -2,7 +2,8 @@
# error "this header file must not be included directly"
#endif
-PyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
+// Alias for backport compatibility
+#define _PyLong_AsInt PyLong_AsInt
PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *);
PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *);
diff --git a/Include/longobject.h b/Include/longobject.h
index e559e23..7393254 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -18,12 +18,18 @@ PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
PyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
+
PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *);
PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *);
PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
+
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
+PyAPI_FUNC(int) PyLong_AsInt(PyObject *);
+#endif
+
PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
/* It may be useful in the future. I've added it in the PyInt -> PyLong