Commit d6625e2b authored by da-woods's avatar da-woods Committed by GitHub

Make __PYX_WARN_IF_INIT_CALLED name unique per-module in generated header files (GH-4309)

Fixes https://github.com/cython/cython/issues/4308
parent e46e9dd7
......@@ -311,12 +311,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
h_code_main.putln('__declspec(deprecated(%s)) __inline' % (
warning_string.as_c_string_literal()))
h_code_main.putln('#endif')
h_code_main.putln("static PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject* res) {")
h_code_main.putln("static PyObject* __PYX_WARN_IF_%s_INIT_CALLED(PyObject* res) {" % py3_mod_func_name)
h_code_main.putln("return res;")
h_code_main.putln("}")
# Function call is converted to warning macro; uncalled (pointer) is not
h_code_main.putln('#define %s() __PYX_WARN_IF_INIT_CALLED(%s())' % (
py3_mod_func_name, py3_mod_func_name))
h_code_main.putln('#define %s() __PYX_WARN_IF_%s_INIT_CALLED(%s())' % (
py3_mod_func_name, py3_mod_func_name, py3_mod_func_name))
h_code_main.putln('#endif')
h_code_main.putln('#endif')
......
PYTHON setup.py build_ext --inplace
############# setup.py #############
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize(["a.pyx", "b.pyx", "include_both.pyx"]),
)
############# a.pyx ###############
cdef public f():
pass
############# b.pyx ###############
cdef public g():
pass
############# include_both.pyx ####
# This is just checking that a and b don't duplicate any names
# and thus it's possible to include them both in one place
cdef extern from "a.h":
pass
cdef extern from "b.h":
pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment