Skip to content

Commit c55e5ee

Browse files
committed
FIX: change c includes to account for upstream changes
python/cpython#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.
1 parent 1461e51 commit c55e5ee

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Cython/Includes/cpython/longintrepr.pxd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
# Internals of the "long" type (Python 2) or "int" type (Python 3).
22
# This is not part of Python's published API.
33

4-
cdef extern from "longintrepr.h":
4+
cdef extern from *:
5+
""""
6+
#if PY_VERSION_HEX >= 0x03000000
7+
#include "Python.h"
8+
#else
9+
#include "longintrepr.h"
10+
#endif
11+
"""
512
ctypedef unsigned int digit
613
ctypedef int sdigit # Python >= 2.7 only
714

Cython/Utility/ModuleSetupCode.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@
263263
#define CYTHON_BACKPORT_VECTORCALL (CYTHON_METH_FASTCALL && PY_VERSION_HEX < 0x030800B1)
264264

265265
#if CYTHON_USE_PYLONG_INTERNALS
266-
#include "longintrepr.h"
266+
#if PY_VERSION_HEX >= 0x03000000
267+
#include "Python.h"
268+
#else
269+
#include "longintrepr.h"
270+
#endif
267271
/* These short defines can easily conflict with other code */
268272
#undef SHIFT
269273
#undef BASE

tests/compile/pylong.pyx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# mode: compile
22

3-
cdef extern from "Python.h":
3+
cdef extern from *:
4+
""""
5+
#if PY_VERSION_HEX >= 0x03000000
6+
#include "Python.h"
7+
#else
8+
#include "longintrepr.h"
9+
#endif
10+
"""
411
ctypedef struct PyTypeObject:
512
pass
613

714
ctypedef struct PyObject:
815
Py_ssize_t ob_refcnt
916
PyTypeObject *ob_type
1017

11-
cdef extern from "longintrepr.h":
18+
cdef extern from "Python.h":
1219
cdef struct _longobject:
1320
int ob_refcnt
1421
PyTypeObject *ob_type

0 commit comments

Comments
 (0)