Skip to content

Commit

Permalink
Change CyFunction to compile with Py_LIMITED_API (#5556)
Browse files Browse the repository at this point in the history
Mostly that we store the PyCFunctionObject as an attribute of
it rather than "inheriting" from PyCFunctionObject.
  • Loading branch information
da-woods committed Jul 23, 2023
1 parent 3ff9bff commit 9c32681
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 18 deletions.
10 changes: 9 additions & 1 deletion Cython/Compiler/ModuleNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,15 @@ def generate_module_preamble(self, env, options, cimported_modules, metadata, co
code.globalstate["end"].putln("#endif /* Py_PYTHON_H */")

from .. import __version__
code.putln('#define CYTHON_ABI "%s"' % __version__.replace('.', '_'))
code.putln('#if CYTHON_LIMITED_API') # CYTHON_COMPILING_IN_LIMITED_API not yet defined
# The limited API makes some significant changes to data structures, so we don't
# want to shared implementation compiled with and without the limited API.
code.putln('#define __PYX_EXTRA_ABI_MODULE_NAME "limited"')
code.putln('#else')
code.putln('#define __PYX_EXTRA_ABI_MODULE_NAME ""')
code.putln('#endif')
code.putln('#define CYTHON_ABI "%s" __PYX_EXTRA_ABI_MODULE_NAME' %
__version__.replace('.', '_'))
code.putln('#define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI')
code.putln('#define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."')
code.putln('#define CYTHON_HEX_VERSION %s' % build_hex_version(__version__))
Expand Down

0 comments on commit 9c32681

Please sign in to comment.