diff options
author | Matthias Urlichs <matthias@urlichs.de> | 2023-10-06 21:02:43 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-10-09 09:46:02 +1100 |
commit | 3fb1bb131f43207e2201a61139cd3f6e82d6513f (patch) | |
tree | 65b05255a532421a8d2384ff2dd6b6351ee4ca10 /tests/basics/exception_chain.py | |
parent | 5232847771903e9022c8c67a436b0562e4530602 (diff) |
py/vm: Don't emit warning when using "raise ... from None".
"Raise SomeException() from None" is a common Python idiom to suppress
chained exceptions and thus shouldn't trigger a warning on a version of
Python that doesn't support them in the first place.
Diffstat (limited to 'tests/basics/exception_chain.py')
-rw-r--r-- | tests/basics/exception_chain.py | 9 |
1 files changed, 9 insertions, 0 deletions
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) |