Commit f0efaf57 authored by Haoyu Bai's avatar Haoyu Bai

prevent the directive dicts from being shared among nodes and compilations

parent 3069c3e5
......@@ -925,9 +925,11 @@ class CVarDefNode(StatNode):
child_attrs = ["base_type", "declarators"]
decorators = None
directive_locals = {}
directive_locals = None
def analyse_declarations(self, env, dest_scope = None):
if self.directive_locals is None:
self.directive_locals = {}
if not dest_scope:
dest_scope = env
self.dest_scope = dest_scope
......@@ -962,7 +964,7 @@ class CVarDefNode(StatNode):
cname = cname, visibility = self.visibility, in_pxd = self.in_pxd,
api = self.api)
if entry is not None:
entry.directive_locals = self.directive_locals
entry.directive_locals = copy.copy(self.directive_locals)
else:
if self.directive_locals:
error(self.pos, "Decorators can only be followed by functions")
......@@ -1638,12 +1640,14 @@ class CFuncDefNode(FuncDefNode):
inline_in_pxd = False
decorators = None
directive_locals = {}
directive_locals = None
def unqualified_name(self):
return self.entry.name
def analyse_declarations(self, env):
if self.directive_locals is None:
self.directive_locals = {}
self.directive_locals.update(env.directives['locals'])
base_type = self.base_type.analyse(env)
# The 2 here is because we need both function and argument names.
......
......@@ -584,7 +584,7 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
super(InterpretCompilerDirectives, self).__init__(context)
self.compilation_directive_defaults = {}
for key, value in compilation_directive_defaults.items():
self.compilation_directive_defaults[unicode(key)] = value
self.compilation_directive_defaults[unicode(key)] = copy.deepcopy(value)
self.cython_module_names = cython.set()
self.directive_names = {}
......@@ -604,8 +604,8 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
self.wrong_scope_error(node.pos, key, 'module')
del node.directive_comments[key]
directives = copy.copy(Options.directive_defaults)
directives.update(self.compilation_directive_defaults)
directives = copy.deepcopy(Options.directive_defaults)
directives.update(copy.deepcopy(self.compilation_directive_defaults))
directives.update(node.directive_comments)
self.directives = directives
node.directives = directives
......
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