Skip to content

Add Python 3.14 bytecode support and improve 3.13/3.14 recovery#605

Open
Techuouo520 wants to merge 2 commits into
zrax:masterfrom
Techuouo520:python
Open

Add Python 3.14 bytecode support and improve 3.13/3.14 recovery#605
Techuouo520 wants to merge 2 commits into
zrax:masterfrom
Techuouo520:python

Conversation

@Techuouo520
Copy link
Copy Markdown

This PR adds Python 3.14 bytecode support and improves recovery for newer Python 3.13/3.14 bytecode patterns.

Changes

  • Add Python 3.14 magic number recognition.
  • Add Python 3.14 opcode metadata/mapping.
  • Enable Python 3.14 in supported version checks.
  • Add Python 3.14 marshal slice object support.
  • Add cache-aware instruction offset handling for Python 3.12+ jump targets.
  • Improve pycdas operand formatting for newer opcodes.
  • Improve best-effort pycdc recovery for unsupported or partially supported bytecode.

Opcode Support / Improvements

Added or improved handling for:

  • CALL_KW
  • INSTRUMENTED_CALL_KW
  • CALL_FUNCTION_EX
  • INSTRUMENTED_CALL_FUNCTION_EX
  • MAKE_FUNCTION
  • SET_FUNCTION_ATTRIBUTE
  • TO_BOOL
  • FORMAT_SIMPLE
  • FORMAT_WITH_SPEC
  • CONVERT_VALUE
  • MAKE_CELL
  • COPY_FREE_VARS
  • LOAD_FAST_CHECK
  • LOAD_FAST_AND_CLEAR
  • LOAD_FAST_BORROW
  • LOAD_FAST_BORROW_LOAD_FAST_BORROW
  • LOAD_SMALL_INT
  • LOAD_COMMON_CONSTANT
  • LOAD_SPECIAL
  • STORE_FAST_LOAD_FAST
  • STORE_FAST_STORE_FAST
  • MAP_ADD
  • DICT_UPDATE
  • DICT_MERGE
  • CALL_INTRINSIC_1
  • CALL_INTRINSIC_2
  • POP_ITER
  • NOT_TAKEN
  • END_ASYNC_FOR
  • EXTENDED_ARG
  • Python 3.14 instrumented opcode variants

Fixes

  • Fix Python 3.14 .pyc files being reported as unknown magic / unsupported version.
  • Fix Python 3.11+ CALL / CALL_KW NULL self-slot handling.
  • Fix keyword-call recovery such as json.dumps(..., ensure_ascii=False).
  • Fix Python 3.13 MAKE_FUNCTION handling.
  • Fix Python 3.13 SET_FUNCTION_ATTRIBUTE handling.
  • Fix Python 3.14 BINARY_OP subscription handling.
  • Fix relative jump target calculation around inline cache entries.
  • Improve fallback behavior for unsupported newer bytecode.
  • Improve Python 3.9/3.10 try / except recovery around JUMP_IF_NOT_EXC_MATCH.
  • Skip synthetic except X as e cleanup patterns such as e = None; del e.
  • Increase MSVC pycdc.exe stack reserve to better handle deeply nested / obfuscated bytecode.

Tests

  • Added a Python 3.13 CALL_KW regression test.
  • Tested Python 3.14 .pyc recognition and disassembly.
  • Tested best-effort decompilation on Python 3.14-generated .pyc files.

Related Issues

Fixes #603
Fixes #587
Fixes #542
Fixes #569
Fixes #595
Refs #540
Refs #498

Notes

Python 3.14 source decompilation is still best-effort. Complex or heavily obfuscated control flow may still produce imperfect source output or placeholder conditions, but the files should now be recognized and disassembled instead of failing at magic/version detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant