summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas A Caswell <tcaswell@gmail.com>2021-10-31 05:11:09 -0400
committerGitHub <noreply@github.com>2021-10-31 10:11:09 +0100
commit60ec08b392cd9f77915deb13ae2282ea71b81f63 (patch)
tree32aeba4c15ee033d1da441730e27e9b0949e8b09
parent09cbf492dfcf1ad022e79660d6aec0be3f444244 (diff)
downloadcython-60ec08b392cd9f77915deb13ae2282ea71b81f63.tar.gz
Change C includes of "longintrepr.h" to account for upstream changes (GH-4428)
See https://github.com/python/cpython/pull/28968/8e5de40f90476249e9a2e5ef135143b5c6a0b512 which is part of implementing https://bugs.python.org/issue35134 moved the header "longintrepr.h" into a sub-folder. The notes on this change suggested to include "Python.h" instead.
-rw-r--r--Cython/Includes/cpython/longintrepr.pxd8
-rw-r--r--Cython/Utility/ModuleSetupCode.c4
-rw-r--r--tests/compile/pylong.pyx7
3 files changed, 15 insertions, 4 deletions
diff --git a/Cython/Includes/cpython/longintrepr.pxd b/Cython/Includes/cpython/longintrepr.pxd
index 45fe81e6c..c38c1bff8 100644
--- a/Cython/Includes/cpython/longintrepr.pxd
+++ b/Cython/Includes/cpython/longintrepr.pxd
@@ -1,7 +1,11 @@
# Internals of the "long" type (Python 2) or "int" type (Python 3).
-# This is not part of Python's published API.
-cdef extern from "longintrepr.h":
+cdef extern from "Python.h":
+ """
+ #if PY_MAJOR_VERSION < 3
+ #include "longintrepr.h"
+ #endif
+ """
ctypedef unsigned int digit
ctypedef int sdigit # Python >= 2.7 only
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index 758ce7f86..369823c69 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -263,7 +263,9 @@
#define CYTHON_BACKPORT_VECTORCALL (CYTHON_METH_FASTCALL && PY_VERSION_HEX < 0x030800B1)
#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
+ #if PY_MAJOR_VERSION < 3
+ #include "longintrepr.h"
+ #endif
/* These short defines can easily conflict with other code */
#undef SHIFT
#undef BASE
diff --git a/tests/compile/pylong.pyx b/tests/compile/pylong.pyx
index f4938fab9..0daef8d4d 100644
--- a/tests/compile/pylong.pyx
+++ b/tests/compile/pylong.pyx
@@ -8,7 +8,12 @@ cdef extern from "Python.h":
Py_ssize_t ob_refcnt
PyTypeObject *ob_type
-cdef extern from "longintrepr.h":
+cdef extern from "Python.h":
+ """
+ #if PY_MAJOR_VERSION < 3
+ #include "longintrepr.h"
+ #endif
+ """
cdef struct _longobject:
int ob_refcnt
PyTypeObject *ob_type