Skip to content

Commit

Permalink
FIX: change c includes to account for upstream changes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tacaswell committed Oct 28, 2021
1 parent 1461e51 commit 98bdc1e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Cython/Includes/cpython/longintrepr.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# 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 *:
""""
#if PY_VERSION_HEX >= 0x03000000
#include "Python.h"
#else
#include "longintrepr.h"
#endif
"""
ctypedef unsigned int digit
ctypedef int sdigit # Python >= 2.7 only

Expand Down
6 changes: 5 additions & 1 deletion Cython/Utility/ModuleSetupCode.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@
#define CYTHON_BACKPORT_VECTORCALL (CYTHON_METH_FASTCALL && PY_VERSION_HEX < 0x030800B1)

#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#if PY_VERSION_HEX >= 0x03000000
#include "Python.h"
#else
#include "longintrepr.h"
#endif
/* These short defines can easily conflict with other code */
#undef SHIFT
#undef BASE
Expand Down
18 changes: 16 additions & 2 deletions tests/compile/pylong.pyx
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
# mode: compile

cdef extern from "Python.h":
cdef extern from *:
""""
#if PY_VERSION_HEX >= 0x03000000
#include "Python.h"
#else
#include "longintrepr.h"
#endif
"""
ctypedef struct PyTypeObject:
pass

ctypedef struct PyObject:
Py_ssize_t ob_refcnt
PyTypeObject *ob_type

cdef extern from "longintrepr.h":
cdef extern from *:
""""
#if PY_VERSION_HEX >= 0x03000000
#include "Python.h"
#else
#include "longintrepr.h"
#endif
"""
cdef struct _longobject:
int ob_refcnt
PyTypeObject *ob_type
Expand Down

0 comments on commit 98bdc1e

Please sign in to comment.