From e66a1a3f4aa6b0e976f6fe9ac17679407cd27080 Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Mon, 12 Jan 2026 13:44:37 +0100 Subject: [PATCH] tests/basics/try_finally: Fix try/finally flow tests under CPython 3.14. This commit fixes tests that will always fail when using CPython 3.14 to get a known-good output to compare MicroPython's behaviour against. Starting from CPython 3.14, statements inside a `finally` block that will prevent the execution flow to reach the block's last statement will raise a SyntaxWarning. That text would end up in the comparison data and thus make known-good tests fail. Given that those tests explicitly exercise flow control interruptions in finally blocks, there is no real workaround that can be applied to the tests themselves. Therefore those tests will now check MicroPython's behaviour against expected output files recorded from the tests' output with CPython 3.11. Signed-off-by: Alessandro Gatti --- tests/basics/try_finally_break.py.exp | 25 ++++++++++++++++ tests/basics/try_finally_break2.py.exp | 17 +++++++++++ tests/basics/try_finally_continue.py.exp | 9 ++++++ tests/basics/try_finally_return2.py.exp | 19 ++++++++++++ tests/basics/try_finally_return3.py.exp | 23 ++++++++++++++ tests/basics/try_finally_return4.py.exp | 38 ++++++++++++++++++++++++ tests/basics/try_finally_return5.py.exp | 3 ++ 7 files changed, 134 insertions(+) create mode 100644 tests/basics/try_finally_break.py.exp create mode 100644 tests/basics/try_finally_break2.py.exp create mode 100644 tests/basics/try_finally_continue.py.exp create mode 100644 tests/basics/try_finally_return2.py.exp create mode 100644 tests/basics/try_finally_return3.py.exp create mode 100644 tests/basics/try_finally_return4.py.exp create mode 100644 tests/basics/try_finally_return5.py.exp diff --git a/tests/basics/try_finally_break.py.exp b/tests/basics/try_finally_break.py.exp new file mode 100644 index 0000000000..d0b3698548 --- /dev/null +++ b/tests/basics/try_finally_break.py.exp @@ -0,0 +1,25 @@ +1 +2 +5 +a 1 +1 +iter 0 +1 +None +1 +2 +None +1 +2 +None +1 +3 +4 +7 +1 +2 +4 +7 +1 +4 +7 diff --git a/tests/basics/try_finally_break2.py.exp b/tests/basics/try_finally_break2.py.exp new file mode 100644 index 0000000000..bc5e931fdb --- /dev/null +++ b/tests/basics/try_finally_break2.py.exp @@ -0,0 +1,17 @@ +4 0 0 1 +4 0 0 2 +4 0 0 3 +4 0 0 4 +4 1 0 1 +4 1 0 2 +4 1 0 3 +4 1 0 4 +4 2 0 1 +4 2 0 2 +4 2 0 3 +4 2 0 4 +4 3 0 1 +4 3 0 2 +4 3 0 3 +4 3 0 4 +None diff --git a/tests/basics/try_finally_continue.py.exp b/tests/basics/try_finally_continue.py.exp new file mode 100644 index 0000000000..2901997b1a --- /dev/null +++ b/tests/basics/try_finally_continue.py.exp @@ -0,0 +1,9 @@ +4 0 +continue +4 1 +continue +4 2 +continue +4 3 +continue +None diff --git a/tests/basics/try_finally_return2.py.exp b/tests/basics/try_finally_return2.py.exp new file mode 100644 index 0000000000..b4c364f81d --- /dev/null +++ b/tests/basics/try_finally_return2.py.exp @@ -0,0 +1,19 @@ +finally +0 +finally 1 +finally 2 +2 +finally 1 +finally 2 +1 +finally 1 +finally 2 +2 +finally +0 +finally +0 +finally +0 +finally +0 diff --git a/tests/basics/try_finally_return3.py.exp b/tests/basics/try_finally_return3.py.exp new file mode 100644 index 0000000000..5fef648ea6 --- /dev/null +++ b/tests/basics/try_finally_return3.py.exp @@ -0,0 +1,23 @@ +1 +42 +1 +2 +42 +1 +2 +3 +42 +2 +1 +42 +2 +1 +42 +1 +3 +2 +42 +1 +3 +2 +42 diff --git a/tests/basics/try_finally_return4.py.exp b/tests/basics/try_finally_return4.py.exp new file mode 100644 index 0000000000..f92572ff61 --- /dev/null +++ b/tests/basics/try_finally_return4.py.exp @@ -0,0 +1,38 @@ +1 +2 +3 +4 +5 +None +1 +2 +3 +5 +42 +1 +2 +5 +43 +1 +2 +5 +43 +1 +2 +5 +caught +1 +2 +5 +caught +1 +2 +3 +4 +5 +None +1 +2 +3 +5 +42 diff --git a/tests/basics/try_finally_return5.py.exp b/tests/basics/try_finally_return5.py.exp new file mode 100644 index 0000000000..dfa403cfd4 --- /dev/null +++ b/tests/basics/try_finally_return5.py.exp @@ -0,0 +1,3 @@ +4 0 +return +43