Commit 175b00de authored by da-woods's avatar da-woods Committed by Stefan Behnel

Include utility code for inline memoryview functions found in .pxd files (GH-4134)

The utility code was generated at too late a stage, after the utility code from the pxd was merged into the pyx scope.

Fixes #1415
parent a89a8812
......@@ -12972,12 +12972,11 @@ class CoerceToMemViewSliceNode(CoercionNode):
CoercionNode.__init__(self, arg)
self.type = dst_type
self.is_temp = 1
self.env = env
self.use_managed_ref = True
self.arg = arg
self.type.create_from_py_utility_code(env)
def generate_result_code(self, code):
self.type.create_from_py_utility_code(self.env)
code.putln(self.type.from_py_call_code(
self.arg.py_result(),
self.result(),
......
# ticket: 1415
# Utility code from an inline function in a pxd file was not
# correctly included in a pyx file that cimported it.
# Do not add more to this test - it is intentionally minimal
# to avoid including the utility code through other means
PYTHON setup.py build_ext --inplace
PYTHON -c "import uses_inline; uses_inline.main()"
######## setup.py ########
from distutils.core import setup
from Cython.Distutils import build_ext
from Cython.Distutils.extension import Extension
setup(
ext_modules = [
Extension("uses_inline", ["uses_inline.pyx"]),
],
cmdclass={'build_ext': build_ext},
)
######## has_inline.pxd ########
from libc.stdlib cimport malloc
cdef inline double[::1] mview(size_t size):
return <double[:size:1]>malloc(size * sizeof(double))
######## uses_inline.pyx ########
from has_inline cimport mview
def main():
return mview(1)
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