Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant xdis Python bytecode 3.9.0 (3425) - assertion error #137

Closed
greenozon opened this issue Aug 5, 2024 · 2 comments
Closed

Cant xdis Python bytecode 3.9.0 (3425) - assertion error #137

greenozon opened this issue Aug 5, 2024 · 2 comments

Comments

@greenozon
Copy link
Contributor

greenozon commented Aug 5, 2024

Description

cannot xdis Python bytecode 3.9.0

How to Reproduce

disasm -S -F extended a-issue438.pyc

Output Given

............

# Method Name:       copy_file_to_output_cache
# Filename:          <frozen depth_utils.output_utils>
# Argument count:    4
# Position-only argument count: 0
# Keyword-only arguments: 0
# Number of locals:  6
# Stack size:        10
# Flags:             0x62000043 (0x40000000 | 0x20000000 | 0x2000000 | NOFREE | NEWLOCALS | OPTIMIZED)
# First Line:        145
# Constants:
#    0: None
#    1: True
#    2: ('parents', 'exist_ok')
#    3: 'Failed to mkdir for '
#    4: '. Ignore error and continue. '
#    5: '.'
# Names:
#    0: Path
#    1: mkdir
#    2: Exception
#    3: logging
#    4: warn
#    5: str
#    6: shutil
#    7: copyfile
# Varnames:
#       in_file_path, job_id, output_dir, ext, err, out_file_path
# Positional arguments:
#       in_file_path, job_id, output_dir, ext
# Local variables:
#    4: err
#    5: out_file_path
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Scripts\pydisasm.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\xdis\bin\pydisasm.py", line 81, in main
    disassemble_file(path, sys.stdout, format, show_source=show_source)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\xdis\disasm.py", line 371, in disassemble_file
    disco(
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\xdis\disasm.py", line 175, in disco
    disco_loop(
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\xdis\disasm.py", line 219, in disco_loop
    bytecode.dis(asm_format=asm_format, show_source=show_source) + "\n"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\xdis\bytecode.py", line 519, in dis
    self.disassemble_bytes(
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\xdis\bytecode.py", line 708, in disassemble_bytes
    instr.disassemble(
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\xdis\instruction.py", line 347, in disassemble
    new_repr = opc.opcode_extended_fmt[opc.opname[op]](
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\xdis\opcodes\format\extended.py", line 649, in extended_format_CALL_METHOD
    assert first_arg is not None
AssertionError

Expected behavior

no assertion error, full disasm printed out

Environment

python -V
Python 3.12.2


>pip show xdis
Name: xdis
Version: 6.1.1
Summary: Python cross-version byte-code library and disassembler
Home-page: https://github.com/rocky/python-xdis
Author:
Author-email: Rocky Bernstein <[email protected]>
License: GPL
Location: C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages
Requires: click, six
Required-by:

-->

Workarounds

Use a non-extended format

Priority

Low

Additional Context

N/A

a-issue438.zip

@rocky
Copy link
Owner

rocky commented Aug 5, 2024

Without bytecode attached, there's little I or someone else can do. A workaround it is to change format to something that does not use exeteded, e.g. disasm -S a-issue438.pyc

@greenozon
Copy link
Contributor Author

I"ve attached it (hte .pyc) in the first post - please find the last line
I did drag-n-drop to the edit pane not sure why GH rendered it that way...

@rocky rocky closed this as completed in 5d0d926 Aug 6, 2024
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

No branches or pull requests

2 participants