Commit 66c059d8 authored by Stefan Behnel's avatar Stefan Behnel

repair analysis scope and qualified name of cpdef wrapper node

parent 1b401b30
...@@ -1697,6 +1697,8 @@ if VALUE is not None: ...@@ -1697,6 +1697,8 @@ if VALUE is not None:
def visit_DefNode(self, node): def visit_DefNode(self, node):
node = self.visit_FuncDefNode(node) node = self.visit_FuncDefNode(node)
env = self.current_env() env = self.current_env()
if node.is_wrapper:
env = env.parent_scope
if (not isinstance(node, Nodes.DefNode) or if (not isinstance(node, Nodes.DefNode) or
node.fused_py_func or node.is_generator_body or node.fused_py_func or node.is_generator_body or
not node.needs_assignment_synthesis(env)): not node.needs_assignment_synthesis(env)):
...@@ -1949,13 +1951,29 @@ class CalculateQualifiedNamesTransform(EnvTransform): ...@@ -1949,13 +1951,29 @@ class CalculateQualifiedNamesTransform(EnvTransform):
return node return node
def visit_PyCFunctionNode(self, node): def visit_PyCFunctionNode(self, node):
orig_qualified_name = self.qualified_name[:]
if node.def_node.is_wrapper and self.qualified_name:
assert self.qualified_name[-1] == '<locals>', self.qualified_name
self.qualified_name.pop()
self._set_qualname(node)
else:
self._set_qualname(node, node.def_node.name) self._set_qualname(node, node.def_node.name)
self.visitchildren(node) self.visitchildren(node)
self.qualified_name = orig_qualified_name
return node return node
def visit_DefNode(self, node): def visit_DefNode(self, node):
if node.is_wrapper and self.qualified_name:
assert self.qualified_name[-1] == '<locals>', self.qualified_name
orig_qualified_name = self.qualified_name[:]
self.qualified_name.pop()
self._set_qualname(node)
self._super_visit_FuncDefNode(node)
self.qualified_name = orig_qualified_name
else:
self._set_qualname(node, node.name) self._set_qualname(node, node.name)
return self.visit_FuncDefNode(node) self.visit_FuncDefNode(node)
return node
def visit_FuncDefNode(self, node): def visit_FuncDefNode(self, node):
orig_qualified_name = self.qualified_name[:] orig_qualified_name = self.qualified_name[:]
......
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