circuitpython/tests/basics/try-as-var.py
Paul Sokolovsky f909034400 py: Implement support for "except Exception as var" clause.
For this, needed to implement DELETE_NAME bytecode (because var bound
in except clause is automatically deleted at its end).
http://docs.python.org/3/reference/compound_stmts.html#except :
"When an exception has been assigned using as target, it is cleared at
the end of the except clause."
2014-03-23 22:00:04 +02:00

11 lines
180 B
Python

try:
raise ValueError(534)
except ValueError as e:
print(repr(e))
# Var bound in except block is automatically deleted
try:
e
except NameError:
print("NameError")