summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--py/vm.c6
-rw-r--r--tests/basics/exception_chain.py9
-rw-r--r--tests/basics/exception_chain.py.exp3
3 files changed, 15 insertions, 3 deletions
diff --git a/py/vm.c b/py/vm.c
index 385d13ee4..a7902d927 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -1171,8 +1171,10 @@ unwind_return:
ENTRY(MP_BC_RAISE_FROM): {
MARK_EXC_IP_SELECTIVE();
- mp_warning(NULL, "exception chaining not supported");
- sp--; // ignore (pop) "from" argument
+ mp_obj_t from_value = POP();
+ if (from_value != mp_const_none) {
+ mp_warning(NULL, "exception chaining not supported");
+ }
mp_obj_t obj = mp_make_raise_obj(TOP());
RAISE(obj);
}
diff --git a/tests/basics/exception_chain.py b/tests/basics/exception_chain.py
index c3a7d6b11..14dd6dfba 100644
--- a/tests/basics/exception_chain.py
+++ b/tests/basics/exception_chain.py
@@ -1,6 +1,15 @@
# Exception chaining is not supported, but check that basic
# exception works as expected.
+
try:
raise Exception from None
except Exception:
print("Caught Exception")
+
+try:
+ try:
+ raise ValueError("Value")
+ except Exception as exc:
+ raise RuntimeError("Runtime") from exc
+except Exception as ex2:
+ print("Caught Exception:", ex2)
diff --git a/tests/basics/exception_chain.py.exp b/tests/basics/exception_chain.py.exp
index 13635b3cd..4369e07a2 100644
--- a/tests/basics/exception_chain.py.exp
+++ b/tests/basics/exception_chain.py.exp
@@ -1,2 +1,3 @@
-Warning: exception chaining not supported
Caught Exception
+Warning: exception chaining not supported
+Caught Exception: Runtime