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

Avoid merged-in code picking up directives from main module (GH-3785)

Fixes https://github.com/cython/cython/issues/1071
parent e3586ce2
......@@ -97,6 +97,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# CodeGenerator, and tell that CodeGenerator to generate code
# from multiple sources.
assert isinstance(self.body, Nodes.StatListNode)
if scope.directives != self.scope.directives:
# merged in nodes should keep their original compiler directives
# (for example inline cdef functions)
tree = Nodes.CompilerDirectivesNode(tree.pos, body=tree, directives=scope.directives)
if isinstance(tree, Nodes.StatListNode):
self.body.stats.extend(tree.stats)
else:
......
# mode: run
# tag: inline, pxd
# cython: wraparound = False
__doc__ = u"""
>>> f()
3
......@@ -28,3 +33,12 @@ def i():
def j():
return my_add3(2, 4)
def test_wraparound():
"""
>>> test_wraparound()
1.0
"""
# the wraparound directive from this scope should not affect the inline pxd
a = [ 0.0, 1.0 ]
return inlinepxd_support.index(a)
cdef inline int my_add(int a, int b=1, int c=0):
return a + b + c
cdef inline index(list L):
# This function should *not* be affected by directives set in the outer scope, such as "wraparound".
# See https://github.com/cython/cython/issues/1071
return L[-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