Skip to content

Commit a0178d8

Browse files
committed
Update for merged PEP 803 implementation
1 parent 3e06a12 commit a0178d8

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/cffi/_cffi_include.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828
#if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API)
2929
# ifdef _MSC_VER
3030
# if !defined(_DEBUG) && !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) && !defined(_CFFI_NO_LIMITED_API)
31-
# define Py_LIMITED_API
31+
# if !defined(Py_GIL_DISABLED)
32+
# define Py_LIMITED_API
33+
# else
34+
# define Py_LIMITED_API 0x030f0000
35+
# endif
3236
# endif
37+
3338
# include <pyconfig.h>
3439
/* sanity-check: Py_LIMITED_API will cause crashes if any of these
3540
are also defined. Normally, the Python file PC/pyconfig.h does not
@@ -49,7 +54,11 @@
4954
# else
5055
# include <pyconfig.h>
5156
# if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) && !defined(_CFFI_NO_LIMITED_API)
52-
# define Py_LIMITED_API
57+
# if !defined(Py_GIL_DISABLED)
58+
# define Py_LIMITED_API
59+
# else
60+
# define Py_LIMITED_API 0x030f0000
61+
# endif
5362
# endif
5463
# endif
5564
#endif

src/cffi/setuptools_ext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ def _set_py_limited_api(Extension, kwds):
110110
log.info("Ignoring py_limited_api=True for free-threaded build.")
111111
kwds['py_limited_api'] = False
112112
else:
113-
kwds.setdefault("define_macros", []).append(("_Py_OPAQUE_PYOBJECT", None))
114-
kwds["define_macros"].append(("Py_LIMITED_API", "0x030f0000"))
113+
kwds["define_macros"].append(("Py_TARGET_ABI3T", "0x030f0000"))
115114

116115
if kwds.get('py_limited_api') is False:
117116
# avoid setting Py_LIMITED_API if py_limited_api=False

0 commit comments

Comments
 (0)