rocky / python-xdis

Python cross-version bytecode library and disassembler
GNU General Public License v2.0
292 stars 95 forks source link

key error!!!! #65

Closed ahmedmoselhi closed 4 years ago

ahmedmoselhi commented 4 years ago

$ uncompyle6 -h Traceback (most recent call last): File "/home/ahmedmoselhi/.local/bin/uncompyle6", line 5, in from uncompyle6.bin.uncompile import main_bin File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/uncompyle6/init.py", line 53, in import uncompyle6.semantics.pysource File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/uncompyle6/semantics/pysource.py", line 141, in from uncompyle6.parsers.treenode import SyntaxTree File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/uncompyle6/parsers/treenode.py", line 3, in from uncompyle6.scanners.tok import NoneToken File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/uncompyle6/scanners/tok.py", line 200, in NoneToken = Token("LOAD_CONST", offset=-1, attr=None, pattr=None) File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/uncompyle6/scanners/tok.py", line 86, in init from xdis.std import _std_api File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/xdis/std.py", line 220, in _std_api = make_std_api() File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/xdis/std.py", line 218, in make_std_api return _StdApi(python_version, variant) File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/xdis/std.py", line 73, in init self.opc = opc = get_opcode_module(python_version, variant) File "/home/ahmedmoselhi/.local/lib/python2.7/site-packages/xdis/op_imports.py", line 169, in get_opcode_module return op_imports[canonic_python_version[vers_str]] KeyError: '2.7.18candidate1'

licy183 commented 4 years ago

Are you using Python 2 on Ubuntu 20.04? I have the same problem. You can add this version string in the variable op_imports in the file /usr/local/lib/python2.7/dist-packages/xdis/op_imports.py. Just like this

...
2.7     : opcode_27,
'2.7.18candidate1' : opcode_27,
'3.0'   : opcode_30,
...

And add the version string in the file /usr/local/lib/python2.7/dist-packages/xdis/magic.py at line 358

# "2.7.17rc1 2.7.17candidate1 2.7.17 2.7.18",
"2.7.17rc1 2.7.17candidate1 2.7.17 2.7.18 2.7.18candidate1",
rocky commented 4 years ago

@licy183 If you putt in a PR all add this.

Normally I don't add release candidates, but if Ubuntu 20.04 has this in its default Python, I suppose we'll add it.

ahmedmoselhi commented 4 years ago

Are you using Python 2 on Ubuntu 20.04? I have the same problem. You can add this version string in the variable op_imports in the file /usr/local/lib/python2.7/dist-packages/xdis/op_imports.py. Just like this

...
2.7     : opcode_27,
'2.7.18candidate1' : opcode_27,
'3.0'   : opcode_30,
...

And add the version string in the file /usr/local/lib/python2.7/dist-packages/xdis/magic.py at line 358

# "2.7.17rc1 2.7.17candidate1 2.7.17 2.7.18",
"2.7.17rc1 2.7.17candidate1 2.7.17 2.7.18 2.7.18candidate1",

yes this fixed it .. thnx