Logo
Explore Help
Register Sign In
fengqi/lv_micropython
1
0
Fork 0
You've already forked lv_micropython
Code Issues Pull Requests 1 Actions Packages Projects Releases Wiki Activity
lv_micropython/tests/basics/exception_chain.py

16 lines
361 B
Python
Raw Permalink Normal View History

tests: Add test for exception-chaining raise syntax.
2015-09-01 10:38:09 +03:00
# Exception chaining is not supported, but check that basic
# exception works as expected.
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.
2023-10-06 21:02:43 +02:00
tests: Add test for exception-chaining raise syntax.
2015-09-01 10:38:09 +03:00
try:
raise Exception from None
except Exception:
print("Caught Exception")
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.
2023-10-06 21:02:43 +02:00
try:
try:
raise ValueError("Value")
except Exception as exc:
raise RuntimeError("Runtime") from exc
except Exception as ex2:
print("Caught Exception:", ex2)
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 203ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API