Skip to content

Commit d8dee81

Browse files
authored
Bytecode parity (RustPython#7885)
* Align codegen CFG cleanup with CPython * Align codegen bytecode with CPython 3.14 * Remove remove_jump_target_line_nops The pass dropped a same-line NOP at the start of any jump-targeted block whose body advanced to a later line, but CPython's basicblock_remove_redundant_nops only consults the previous/next instruction inside the same block. The extra pass deleted the else-body line trace anchor exercised by test_nested_double_async_with. Ignore test_conditional_break_finally_does_not_keep_break_cleanup_nop; the break NOP lands in a separate block from the inlined finally body, so same-line successor elision does not apply here. * Keep except_handler blocks reachable in eliminate_unreachable_blocks After convert_pseudo_ops lowers SETUP_FINALLY to a plain NOP, the only remaining link from the try body to the except_handler block was the per-instruction except_handler annotation. When earlier passes had already removed every NOP that carried that annotation (e.g. an empty try body with `pass`), the handler block became unreachable from the entry block and its instructions were cleared, dropping the handler entirely. Seed reachability with blocks already marked except_handler so handler dispatch survives independent of the in-block annotation. Also drop two expectedFailure markers in test_patma whose match-tracing expectations now pass. * Align bytecode CFG cleanup with CPython
1 parent e8d7437 commit d8dee81

5 files changed

Lines changed: 4819 additions & 9912 deletions

File tree

.cspell.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"words": [
5858
"aiterable",
5959
"alnum",
60+
"csock",
6061
"coro",
6162
"dedentations",
6263
"dedents",
@@ -80,6 +81,8 @@
8081
"reraising",
8182
"significand",
8283
"summands",
84+
"TESTFN",
85+
"TZPATH",
8386
"unraisable",
8487
"wasi",
8588
"weaked",

Lib/test/test_patma.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,7 +3433,6 @@ def trace(frame, event, arg):
34333433
sys.settrace(old_trace)
34343434
return actual_linenos
34353435

3436-
@unittest.expectedFailure # TODO: RUSTPYTHON
34373436
def test_default_wildcard(self):
34383437
def f(command): # 0
34393438
match command.split(): # 1
@@ -3494,7 +3493,6 @@ def f(command): # 0
34943493
self.assertListEqual(self._trace(f, "go x"), [1, 2, 3])
34953494
self.assertListEqual(self._trace(f, "spam"), [1, 2, 3])
34963495

3497-
@unittest.expectedFailure # TODO: RUSTPYTHON
34983496
def test_unreachable_code(self):
34993497
def f(command): # 0
35003498
match command: # 1

0 commit comments

Comments
 (0)