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

ImportError: Unknown magic number 227 in file.pyc #164

Closed
theblackturtle opened this issue Mar 26, 2018 · 2 comments
Closed

ImportError: Unknown magic number 227 in file.pyc #164

theblackturtle opened this issue Mar 26, 2018 · 2 comments
Labels
invalid bytecode Bytecode is not the result of Python compilation. It may have been altered in some way unresponsive user

Comments

@theblackturtle
Copy link

Hi, I have a problem when I run "uncompyle6 MegarangerCLI.pyc"

Traceback (most recent call last):
  File "/usr/bin/uncompyle6", line 11, in <module>
    load_entry_point('uncompyle6', 'console_scripts', 'uncompyle6')()
  File "/home/beo/Downloads/python-uncompyle6-release-python-2.4-3.1.0/uncompyle6/bin/uncompile.py", line 172, in main_bin
    **options)
  File "/home/beo/Downloads/python-uncompyle6-release-python-2.4-3.1.0/uncompyle6/main.py", line 226, in main
    linemap_stream, do_fragments)
  File "/home/beo/Downloads/python-uncompyle6-release-python-2.4-3.1.0/uncompyle6/main.py", line 137, in decompile_file
    source_size) = load_module(filename, code_objects)
  File "/usr/lib/python2.7/site-packages/xdis/load.py", line 108, in load_module
    fast_load=fast_load, get_code=get_code)
  File "/usr/lib/python2.7/site-packages/xdis/load.py", line 139, in load_module_from_file_object
    (ord(magic[0])+256*ord(magic[1]), filename))
ImportError: Unknown magic number 227 in xxx.pyc

Please tell me how to fix it. Thanks

@rocky
Copy link
Owner

rocky commented Mar 26, 2018

Do you have valid bytecode?

Read https://github.com/rocky/python-uncompyle6/blob/master/HOW-TO-REPORT-A-BUG.md#do-you-have-valid-bytecode

If you have valid bytecode you should be able to disassemble it (which is a prerequisite for decompilation) and you should be run python on the bytecode.

@theblackturtle
Copy link
Author

And also this too.

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/xdis/load.py", line 106, in load_module
    version = float(magics.versions[magic][:3])
KeyError: b'\xe3\x00\x00\x00'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./uncompyle6", line 3, in <module>
    main_bin()
  File "/usr/lib/python3.6/site-packages/uncompyle6/bin/uncompile.py", line 163, in main_bin
    **options)
  File "/usr/lib/python3.6/site-packages/uncompyle6/main.py", line 146, in main
    decompile_file(infile, outstream, showasm, showast, showgrammar)
  File "/usr/lib/python3.6/site-packages/uncompyle6/main.py", line 63, in decompile_file
    source_size) = load_module(filename, code_objects)
  File "/usr/lib/python3.6/site-packages/xdis/load.py", line 110, in load_module
    (ord(magic[0])+256*ord(magic[1]), filename))
TypeError: ord() expected string of length 1, but int found

@rocky rocky added unresponsive user invalid bytecode Bytecode is not the result of Python compilation. It may have been altered in some way labels Mar 26, 2018
@rocky rocky closed this as completed Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid bytecode Bytecode is not the result of Python compilation. It may have been altered in some way unresponsive user
Projects
None yet
Development

No branches or pull requests

2 participants