-
-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
I am trying to assemble a pyasm file created by py-xdis, but the resulting pyc produces the following error when ran: "RuntimeError: Bad code object in .pyc file".
I am currently using python 3.8, but I have also tried 3.7, 3.9 and 3.10 with no luck.
The xdis version I use is 6.1.4, and the xasm version I use is the one in the master.
The commands I ran are:
pydisasm -F xasm .\main.py
pyc-xasm .\main.pyasm
python .\main.pyc
The original main.py contents are:
def add(a, b):
return a + b
And the main.pyasm contents are:
# pydisasm version 6.1.4
# Python bytecode 3.8.0 (3413)
# Disassembled from Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
# Timestamp in code: 1750448115 (2025-06-20 22:35:15)
# Source code size mod 2**32: 34 bytes
# Method Name: add
# Filename: .\main.py
# Argument count: 2
# Position-only argument count: 0
# Keyword-only arguments: 0
# Number of locals: 2
# Stack size: 2
# Flags: 0x00000043 (NOFREE | NEWLOCALS | OPTIMIZED)
# First Line: 1
# Constants:
# 0: None
# Varnames:
# a, b
# Positional arguments:
# a, b
2:
LOAD_FAST 0 (a)
LOAD_FAST 1 (b)
BINARY_ADD
RETURN_VALUE
# Method Name: <module>
# Filename: .\main.py
# Argument count: 0
# Position-only argument count: 0
# Keyword-only arguments: 0
# Number of locals: 0
# Stack size: 2
# Flags: 0x00000040 (NOFREE)
# First Line: 1
# Constants:
# 0: <Code38 code object add at 0x1d382179b50, file .\main.py>, line 1
# 1: 'add'
# 2: None
# Names:
# 0: add
1:
LOAD_CONST 0 (<Code38 code object add at 0x1d382179b50, file .\main.py>, line 1)
LOAD_CONST 1 ("add")
MAKE_FUNCTION 0 (No arguments)
STORE_NAME 0 (add)
LOAD_CONST 2 (None)
RETURN_VALUE
Also attached the pyc in question(I have changed it's suffix to txt because github won't let me upload pyc files).
main_pyc.txt
Metadata
Metadata
Assignees
Labels
No labels