cython-devel
changeset 2563:e3c343d38eb8
Fix #250, Traceback method name is wrong for exceptions caught in methods
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Thu Oct 22 23:21:40 2009 -0700 (2 years ago) |
| parents | 47eb2c006fd2 |
| children | 3aa603282788 |
| files | Cython/Compiler/Nodes.py Cython/Compiler/ParseTreeTransforms.py Cython/Compiler/Symtab.py |
line diff
1.1 --- a/Cython/Compiler/Nodes.py Thu Oct 22 22:39:44 2009 -0700
1.2 +++ b/Cython/Compiler/Nodes.py Thu Oct 22 23:21:40 2009 -0700
1.3 @@ -1019,12 +1019,12 @@
1.4
1.5 def create_local_scope(self, env):
1.6 genv = env
1.7 - while env.is_py_class_scope or env.is_c_class_scope:
1.8 - env = env.outer_scope
1.9 + while genv.is_py_class_scope or genv.is_c_class_scope:
1.10 + genv = env.outer_scope
1.11 if self.needs_closure:
1.12 - lenv = GeneratorLocalScope(name = self.entry.name, outer_scope = genv)
1.13 - else:
1.14 - lenv = LocalScope(name = self.entry.name, outer_scope = genv)
1.15 + lenv = GeneratorLocalScope(name = self.entry.name, outer_scope = genv, parent_scope = env)
1.16 + else:
1.17 + lenv = LocalScope(name = self.entry.name, outer_scope = genv, parent_scope = env)
1.18 lenv.return_type = self.return_type
1.19 type = self.entry.type
1.20 if type.is_cfunction:
1.21 @@ -2730,7 +2730,7 @@
1.22 buffer_defaults = buffer_defaults)
1.23 if home_scope is not env and self.visibility == 'extern':
1.24 env.add_imported_entry(self.class_name, self.entry, pos)
1.25 - scope = self.entry.type.scope
1.26 + self.scope = scope = self.entry.type.scope
1.27 if scope is not None:
1.28 scope.directives = env.directives
1.29
2.1 --- a/Cython/Compiler/ParseTreeTransforms.py Thu Oct 22 22:39:44 2009 -0700
2.2 +++ b/Cython/Compiler/ParseTreeTransforms.py Thu Oct 22 23:21:40 2009 -0700
2.3 @@ -698,6 +698,12 @@
2.4 self.visitchildren(node)
2.5 self.seen_vars_stack.pop()
2.6 return node
2.7 +
2.8 + def visit_ClassDefNode(self, node):
2.9 + self.env_stack.append(node.scope)
2.10 + self.visitchildren(node)
2.11 + self.env_stack.pop()
2.12 + return node
2.13
2.14 def visit_FuncDefNode(self, node):
2.15 self.seen_vars_stack.append(set())
3.1 --- a/Cython/Compiler/Symtab.py Thu Oct 22 22:39:44 2009 -0700
3.2 +++ b/Cython/Compiler/Symtab.py Thu Oct 22 23:21:40 2009 -0700
3.3 @@ -1066,8 +1066,10 @@
3.4
3.5 class LocalScope(Scope):
3.6
3.7 - def __init__(self, name, outer_scope):
3.8 - Scope.__init__(self, name, outer_scope, outer_scope)
3.9 + def __init__(self, name, outer_scope, parent_scope = None):
3.10 + if parent_scope is None:
3.11 + parent_scope = outer_scope
3.12 + Scope.__init__(self, name, outer_scope, parent_scope)
3.13
3.14 def mangle(self, prefix, name):
3.15 return prefix + name
