Skip to content

Add Python 3.11/3.12 opcode handlers to reduce decompilation failures#602

Open
gustavomfc wants to merge 1 commit into
zrax:masterfrom
gustavomfc:master
Open

Add Python 3.11/3.12 opcode handlers to reduce decompilation failures#602
gustavomfc wants to merge 1 commit into
zrax:masterfrom
gustavomfc:master

Conversation

@gustavomfc
Copy link
Copy Markdown

No-op prologue/bookkeeping opcodes:

  • MAKE_CELL_A: closure cell initialization (Python 3.11+)
  • COPY_FREE_VARS_A: copies free vars into frame at function entry (3.11+)
  • RETURN_GENERATOR: marks a function as a generator (3.12)

Stack/call opcodes:

  • YIELD_VALUE_A: generator yield with stack-depth operand (3.12)
  • CALL_FUNCTION_EX_A / INSTRUMENTED_CALL_FUNCTION_EX_A: func(*args, **kwargs)
  • LOAD_SUPER_ATTR_A: super().attr access (3.12 specialization)
  • LOAD_FROM_DICT_OR_DEREF_A: closure variable load (3.12)

Comprehension opcodes:

  • SET_ADD_A: set comprehension element append
  • MAP_ADD_A: dict comprehension key/value append
  • DICT_UPDATE_A: in-place dict merge (like SET_UPDATE_A for dicts)

Other opcodes:

  • LOAD_ASSERTION_ERROR: pushes AssertionError class (used in assert stmts)
  • DICT_MERGE_A: merges **kwargs mapping into accumulator dict
  • CALL_INTRINSIC_1_A: Python-internal intrinsic functions (pass-through)
  • POP_JUMP_IF_NONE_A / POP_JUMP_IF_NOT_NONE_A: None-checking conditional jumps
  • LOAD_FAST_CHECK_A / LOAD_FAST_AND_CLEAR_A: variants of LOAD_FAST

Bug fixes:

  • Restore accidentally-removed 'case Pyc::LOAD_ATTR_A:' label that was clobbered when inserting the DICT_MERGE_A handler
  • Handle NODE_TUPLE (and other unexpected node types) inside f-string (NODE_JOINEDSTR) value lists by wrapping them in { } instead of emitting 'Unsupported node type' and marking cleanBuild=false

No-op prologue/bookkeeping opcodes:
- MAKE_CELL_A: closure cell initialization (Python 3.11+)
- COPY_FREE_VARS_A: copies free vars into frame at function entry (3.11+)
- RETURN_GENERATOR: marks a function as a generator (3.12)

Stack/call opcodes:
- YIELD_VALUE_A: generator yield with stack-depth operand (3.12)
- CALL_FUNCTION_EX_A / INSTRUMENTED_CALL_FUNCTION_EX_A: func(*args, **kwargs)
- LOAD_SUPER_ATTR_A: super().attr access (3.12 specialization)
- LOAD_FROM_DICT_OR_DEREF_A: closure variable load (3.12)

Comprehension opcodes:
- SET_ADD_A: set comprehension element append
- MAP_ADD_A: dict comprehension key/value append
- DICT_UPDATE_A: in-place dict merge (like SET_UPDATE_A for dicts)

Other opcodes:
- LOAD_ASSERTION_ERROR: pushes AssertionError class (used in assert stmts)
- DICT_MERGE_A: merges **kwargs mapping into accumulator dict
- CALL_INTRINSIC_1_A: Python-internal intrinsic functions (pass-through)
- POP_JUMP_IF_NONE_A / POP_JUMP_IF_NOT_NONE_A: None-checking conditional jumps
- LOAD_FAST_CHECK_A / LOAD_FAST_AND_CLEAR_A: variants of LOAD_FAST

Bug fixes:
- Restore accidentally-removed 'case Pyc::LOAD_ATTR_A:' label that was
  clobbered when inserting the DICT_MERGE_A handler
- Handle NODE_TUPLE (and other unexpected node types) inside f-string
  (NODE_JOINEDSTR) value lists by wrapping them in { } instead of
  emitting 'Unsupported node type' and marking cleanBuild=false

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