[pypy-dev] [pypy-commit] pypy py3k: The exception handler target "except ValueError as exc" was always compiled as a global variable. Test and fix.
Maciej Fijalkowski
fijall at gmail.com
Mon Jan 23 09:08:31 CET 2012
Shouldn't that go to trunk as well?
On Sun, Jan 22, 2012 at 1:10 PM, amauryfa <noreply at buildbot.pypy.org> wrote:
> Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
> Branch: py3k
> Changeset: r51639:e325e4d3227a
> Date: 2012-01-22 12:02 +0100
> http://bitbucket.org/pypy/pypy/changeset/e325e4d3227a/
>
> Log: The exception handler target "except ValueError as exc" was always
> compiled as a global variable. Test and fix.
>
> diff --git a/pypy/interpreter/astcompiler/symtable.py b/pypy/interpreter/astcompiler/symtable.py
> --- a/pypy/interpreter/astcompiler/symtable.py
> +++ b/pypy/interpreter/astcompiler/symtable.py
> @@ -417,6 +417,11 @@
> def visit_alias(self, alias):
> self._visit_alias(alias)
>
> + def visit_ExceptHandler(self, handler):
> + if handler.name:
> + self.note_symbol(handler.name, SYM_ASSIGNED)
> + ast.GenericASTVisitor.visit_ExceptHandler(self, handler)
> +
> def visit_Yield(self, yie):
> self.scope.note_yield(yie)
> ast.GenericASTVisitor.visit_Yield(self, yie)
> diff --git a/pypy/interpreter/astcompiler/test/test_symtable.py b/pypy/interpreter/astcompiler/test/test_symtable.py
> --- a/pypy/interpreter/astcompiler/test/test_symtable.py
> +++ b/pypy/interpreter/astcompiler/test/test_symtable.py
> @@ -142,6 +142,10 @@
> scp = self.func_scope("def f(): x")
> assert scp.lookup("x") == symtable.SCOPE_GLOBAL_IMPLICIT
>
> + def test_exception_variable(self):
> + scp = self.mod_scope("try: pass\nexcept ValueError as e: pass")
> + assert scp.lookup("e") == symtable.SCOPE_LOCAL
> +
> def test_nested_scopes(self):
> def nested_scope(*bodies):
> names = enumerate("f" + string.ascii_letters)
> _______________________________________________
> pypy-commit mailing list
> pypy-commit at python.org
> http://mail.python.org/mailman/listinfo/pypy-commit
More information about the pypy-dev
mailing list