Commit a73a141
committed
Add Python 3.14 opcode support and 3.11+ zero-cost exception decompilation
Extend the decompiler to handle Python 3.14 bytecode and reconstruct
try/except/finally from the zero-cost exception model introduced in 3.11.
Python 3.14:
- Update the 3.14 magic number and remap opcodes to their argument-bearing
forms (LOAD_FAST_BORROW, LOAD_COMMON_CONSTANT, LOAD_SPECIAL,
BUILD_INTERPOLATION, STORE_FAST_MAYBE_NULL).
- Decode LOAD_SMALL_INT, LOAD_COMMON_CONSTANT, LOAD_SPECIAL, and the
LOAD_FAST_BORROW family; treat LOAD_FAST_CHECK as a plain fast load.
- Reconstruct PEP 750 t-strings via BUILD_INTERPOLATION / BUILD_TEMPLATE,
reusing the f-string rendering path and prefixing templates with 't'.
- Normalize the standalone PUSH_NULL layout so CALL sees NULL, callable.
- Skip specialized/adaptive opcodes defensively rather than aborting.
Zero-cost exceptions (3.11+):
- Pre-scan co_exceptiontable to locate try bodies and handlers, then rebuild
try/except/finally structure while walking the linear byte stream.
- Recover `except <type>:`, bare `except:`, and `except ... as <name>`,
suppressing the compiler-generated alias cleanup.
Tests:
- Add except_as covering bare, typed, and aliased except clauses under the
Python 3.14 zero-cost exception layout.1 parent 75c2e8d commit a73a141
8 files changed
Lines changed: 690 additions & 27 deletions
File tree
- bytes
- tests
- compiled
- input
- tokenized
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
581 | 586 | | |
582 | 587 | | |
583 | 588 | | |
| 589 | + | |
584 | 590 | | |
585 | 591 | | |
586 | 592 | | |
| |||
717 | 723 | | |
718 | 724 | | |
719 | 725 | | |
720 | | - | |
721 | | - | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
722 | 729 | | |
723 | 730 | | |
| 731 | + | |
724 | 732 | | |
725 | 733 | | |
726 | 734 | | |
| 735 | + | |
727 | 736 | | |
728 | 737 | | |
729 | 738 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 131 | | |
137 | 132 | | |
138 | 133 | | |
| |||
220 | 215 | | |
221 | 216 | | |
222 | 217 | | |
223 | | - | |
224 | 218 | | |
225 | 219 | | |
226 | 220 | | |
| |||
371 | 365 | | |
372 | 366 | | |
373 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
| 90 | + | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments