Skip to content

Commit

Permalink
avoid setting Py_LIMITED_API when py_limited_api=False (#106)
Browse files Browse the repository at this point in the history
* avoid setting Py_LIMITED_API when py_limited_api=False

previously, setting py_limited_api=False only appeared to affect the ABI tag of modules,
as Py_LIMITED_API was still unconditionally defined in most cases by _cffi_include.h

* only unset limited api for explicit py_limited_api=False
  • Loading branch information
minrk authored Aug 2, 2024
1 parent fb6e5dc commit 16b143d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cffi/setuptools_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def _set_py_limited_api(Extension, kwds):
# try to set 'py_limited_api' anyway. At worst, we get a
# warning.
kwds['py_limited_api'] = True

if kwds.get('py_limited_api') is False:
# avoid setting Py_LIMITED_API if py_limited_api=False
# which _cffi_include.h does unless _CFFI_NO_LIMITED_API is defined
kwds.setdefault("define_macros", []).append(("_CFFI_NO_LIMITED_API", None))
return kwds

def _add_c_module(dist, ffi, module_name, source, source_extension, kwds):
Expand Down

0 comments on commit 16b143d

Please sign in to comment.