Skip to content

Add complete Python 3.14 support with loop/exception handling hardening - #616

Open
zsy-arch wants to merge 1 commit into
zrax:masterfrom
zsy-arch:python3.14-support
Open

zsy-arch wants to merge 1 commit into
zrax:masterfrom
zsy-arch:python3.14-support

Conversation

@zsy-arch

Copy link
Copy Markdown

Bytecode & module layer:

  • Python 3.14 magic numbers and bytecode table (bytecode_ops.inl), bytes/python_3_14.cpp; opcode handling in bytecode.cpp/data.h for CALL_KW, LOAD_CONST folding, RETURN_CONST, JUMP_BACKWARD loops, exception-table (zero-cost try) landing pads.
  • pyc_module/pyc_object: marshal parsing for 3.14 code objects.

ASTree structural reconstruction:

  • Prescan-driven while True: recognition for 3.9+ (no SETUP_LOOP): unconditional-loop heads from JUMP_BACKWARD targets, with rotated-loop condition-head rejection (mid-body conditional exit + protected_cycle exception-entry guard) so rotated inner while loops (quicksort-style) are not misdetected.
  • 3.13/3.14 while-try-finally with continue: handler back-edge targets the condition-evaluation head; finally rendered on both normal and exception paths; deferred in-loop handler containers (pending_conts) with nested-try support.
  • while-else exit transform via JUMP_BACKWARD; dangling WHILE closed on RETURN_VALUE at EOF; EOF-guarded dead-jump probes for both RETURN_VALUE and RETURN_CONST; curpos kept at current-opcode semantics (fixes 3.10 module-level for RETURN duplication and 3.9 yield_from spurious return None).
  • PEP 709 inline-comprehension bookkeeping resets.

Tests (tests/py314_roundtrip):

  • Closed-loop roundtrip runner (compile -> pycdc -> ast.parse -> test probe equivalence) with interpreter autodetection, 21 cases x {3.13, 3.14} including nested loop/exception shapes, algorithms (quicksort, sieve, RC4), tree/graph (BST/BFS/DFS).
  • Validation: roundtrip 42/42, upstream suite 0 FAIL (93 PASS/XFAIL), semantic probe matrix 8/8.

Bytecode & module layer:
- Python 3.14 magic numbers and bytecode table (bytecode_ops.inl),
  bytes/python_3_14.cpp; opcode handling in bytecode.cpp/data.h for
  CALL_KW, LOAD_CONST folding, RETURN_CONST, JUMP_BACKWARD loops,
  exception-table (zero-cost try) landing pads.
- pyc_module/pyc_object: marshal parsing for 3.14 code objects.

ASTree structural reconstruction:
- Prescan-driven `while True:` recognition for 3.9+ (no SETUP_LOOP):
  unconditional-loop heads from JUMP_BACKWARD targets, with
  rotated-loop condition-head rejection (mid-body conditional exit +
  protected_cycle exception-entry guard) so rotated inner while loops
  (quicksort-style) are not misdetected.
- 3.13/3.14 while-try-finally with continue: handler back-edge targets
  the condition-evaluation head; finally rendered on both normal and
  exception paths; deferred in-loop handler containers (pending_conts)
  with nested-try support.
- while-else exit transform via JUMP_BACKWARD; dangling WHILE closed
  on RETURN_VALUE at EOF; EOF-guarded dead-jump probes for both
  RETURN_VALUE and RETURN_CONST; curpos kept at current-opcode
  semantics (fixes 3.10 module-level for RETURN duplication and
  3.9 yield_from spurious return None).
- PEP 709 inline-comprehension bookkeeping resets.

Tests (tests/py314_roundtrip):
- Closed-loop roundtrip runner (compile -> pycdc -> ast.parse ->
  __test__ probe equivalence) with interpreter autodetection,
  21 cases x {3.13, 3.14} including nested loop/exception shapes,
  algorithms (quicksort, sieve, RC4), tree/graph (BST/BFS/DFS).
- Validation: roundtrip 42/42, upstream suite 0 FAIL (93 PASS/XFAIL),
  semantic probe matrix 8/8.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant