Skip to content

can't find method #20

Description

@miuru0

I got this problem: can't find method greet
appending bogus greet to list of constants

when running pyc-xasm --pyc-file test .\compiled_code.pyasm

this is the code that generated compiled_code.pyasm

source_code = """
def greet():
    print("Hello, world!")
"""

compiled_code = compile(source_code, "<string>", "exec")
pyc_file = "compiled_code.pyasm"
with open(pyc_file, "w") as file:
    xdis.std.disassemble(compiled_code, file=file)

and this is the compiled_code:

# pydisasm version 6.0.5
# Python bytecode 3.9 ()
# Disassembled from Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)]
# Method Name:       <module>
# Filename:          <string>
# Argument count:    0
# Position-only argument count: 0
# Keyword-only arguments: 0
# Number of locals:  0
# Stack size:        2
# Flags:             0x00000040 (NOFREE)
# First Line:        2
# Constants:
#    0: <code object greet at 0x000002028CC845B0, file "<string>", line 2>
#    1: 'greet'
#    2: None
# Names:
#    0: greet
  2:           0 LOAD_CONST           (<code object greet at 0x000002028CC845B0, file "<string>", line 2>)
               2 LOAD_CONST           ('greet')
               4 MAKE_FUNCTION        (Neither defaults, keyword-only args, annotations, nor closures)
               6 STORE_NAME           (greet)
               8 LOAD_CONST           (None)
              10 RETURN_VALUE


# Method Name:       greet
# Filename:          <string>
# Argument count:    0
# Position-only argument count: 0
# Keyword-only arguments: 0
# Number of locals:  0
# Stack size:        2
# Flags:             0x00000043 (NOFREE | NEWLOCALS | OPTIMIZED)
# First Line:        2
# Constants:
#    0: None
#    1: 'Hello, world!'
# Names:
#    0: print
  3:           0 LOAD_GLOBAL          (print)
               2 LOAD_CONST           ('Hello, world!')
               4 CALL_FUNCTION        1
               6 POP_TOP
               8 LOAD_CONST           (None)
              10 RETURN_VALUE


Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions