From 20500558f8ca82e1d349a041f6fed8acbd6a2e3d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 14 Oct 2025 18:06:09 -0500 Subject: [PATCH] tests/micropython: Add a test for throwing incomplete exception. This is a reproducer for #17117. Signed-off-by: Jeff Epler --- tests/micropython/incomplete_exc.py | 40 +++++++++++++++++++++++++ tests/micropython/incomplete_exc.py.exp | 5 ++++ 2 files changed, 45 insertions(+) create mode 100644 tests/micropython/incomplete_exc.py create mode 100644 tests/micropython/incomplete_exc.py.exp diff --git a/tests/micropython/incomplete_exc.py b/tests/micropython/incomplete_exc.py new file mode 100644 index 0000000000..2aec9a47b3 --- /dev/null +++ b/tests/micropython/incomplete_exc.py @@ -0,0 +1,40 @@ +# Test raising an incomplete exception. + + +class C(Exception): + def __init__(self): + raise self + + +class C1(C): + pass + + +class B: + pass + + +class C2(B, Exception): + def __init__(self): + raise self + + +class C3(Exception, B): + def __init__(self): + raise self + + +class D(Exception): + pass + + +class C4(D): + def __init__(self): + raise self + + +for cls in C, C1, C2, C3, C4: + try: + cls() + except TypeError as e: + print("TypeError") diff --git a/tests/micropython/incomplete_exc.py.exp b/tests/micropython/incomplete_exc.py.exp new file mode 100644 index 0000000000..f2e9c12f7f --- /dev/null +++ b/tests/micropython/incomplete_exc.py.exp @@ -0,0 +1,5 @@ +TypeError +TypeError +TypeError +TypeError +TypeError