Fix #250, Traceback method name is wrong for exceptions caught in methods
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 23 Oct 2009 06:21:40 +0000 (23:21 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 23 Oct 2009 06:21:40 +0000 (23:21 -0700)
Cython/Compiler/Nodes.py
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/Symtab.py

index 7d22f885b577ba1c596df55a75d5a4c172397614..8b37eb860ca278de894e7572057d113196f30558 100644 (file)
@@ -1019,12 +1019,12 @@ class FuncDefNode(StatNode, BlockNode):
         
     def create_local_scope(self, env):
         genv = env
-        while env.is_py_class_scope or env.is_c_class_scope:
-            env = env.outer_scope
+        while genv.is_py_class_scope or genv.is_c_class_scope:
+            genv = env.outer_scope
         if self.needs_closure:
-            lenv = GeneratorLocalScope(name = self.entry.name, outer_scope = genv)
+            lenv = GeneratorLocalScope(name = self.entry.name, outer_scope = genv, parent_scope = env)
         else:
-            lenv = LocalScope(name = self.entry.name, outer_scope = genv)
+            lenv = LocalScope(name = self.entry.name, outer_scope = genv, parent_scope = env)
         lenv.return_type = self.return_type
         type = self.entry.type
         if type.is_cfunction:
@@ -2730,7 +2730,7 @@ class CClassDefNode(ClassDefNode):
             buffer_defaults = buffer_defaults)
         if home_scope is not env and self.visibility == 'extern':
             env.add_imported_entry(self.class_name, self.entry, pos)
-        scope = self.entry.type.scope
+        self.scope = scope = self.entry.type.scope
         if scope is not None:
             scope.directives = env.directives
 
index 93bf4bc20bda847f44c476b4f74a19b4ae553c7e..34883967aa9064adf7a987e8505b68702cd31c3d 100644 (file)
@@ -698,6 +698,12 @@ property NAME:
         self.visitchildren(node)
         self.seen_vars_stack.pop()
         return node
+    
+    def visit_ClassDefNode(self, node):
+        self.env_stack.append(node.scope)
+        self.visitchildren(node)
+        self.env_stack.pop()
+        return node
         
     def visit_FuncDefNode(self, node):
         self.seen_vars_stack.append(set())
index bb96dd45a844ff5e209d98aaecf4140202ae80fe..5bc9c3c5376cd66ee09752ccd0aed9e94c9265b9 100644 (file)
@@ -1066,8 +1066,10 @@ class ModuleScope(Scope):
         
 class LocalScope(Scope):    
 
-    def __init__(self, name, outer_scope):
-        Scope.__init__(self, name, outer_scope, outer_scope)
+    def __init__(self, name, outer_scope, parent_scope = None):
+        if parent_scope is None:
+            parent_scope = outer_scope
+        Scope.__init__(self, name, outer_scope, parent_scope)
     
     def mangle(self, prefix, name):
         return prefix + name