summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-23 21:19:02 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-23 22:00:04 +0200
commitf909034400b3552c933582357d1986dae5b70d04 (patch)
tree31c68a910a97eccc88bd3df61a94e77a30303afa /tests
parent4b2b7ceca7915d014a191d3776bc29bdbc5faf02 (diff)
downloadmicropython-f909034400b3552c933582357d1986dae5b70d04.tar.gz
micropython-f909034400b3552c933582357d1986dae5b70d04.zip
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."
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/try-as-var.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/basics/try-as-var.py b/tests/basics/try-as-var.py
new file mode 100644
index 0000000000..0a92f1caee
--- /dev/null
+++ b/tests/basics/try-as-var.py
@@ -0,0 +1,10 @@
+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")