Mysterie / uncompyle2

uncompyle2
642 stars 148 forks source link

fails for md5.pyc (wibiti's version works great for same) #15

Closed kholia closed 11 years ago

kholia commented 11 years ago

Trying this version of uncompyle2,


$ git rev-parse HEAD
09b2adbbbde46ce30d3f1a36c83293572f8b56f0

$ uncompyle2 md5.pyc                     
...
# Can't uncompyle /tmp/md5.pyc
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/uncompyle2/__init__.py", line 203, in main
    uncompyle_file(infile, outstream, showasm, showast)
  File "/usr/lib/python2.7/site-packages/uncompyle2/__init__.py", line 135, in uncompyle_file
    version, co = _load_module(filename)
  File "/usr/lib/python2.7/site-packages/uncompyle2/__init__.py", line 76, in _load_module
    co = dis.marshalLoad(fp)
  File "/usr/lib/python2.7/site-packages/uncompyle2/disas.py", line 193, in marshalLoad
    return load(fp)
  File "/usr/lib/python2.7/site-packages/uncompyle2/disas.py", line 205, in load
    co_argcount = unpack('l', fp.read(4))[0]
error: unpack requires a string argument of length 8
# decompiled 0 files: 0 okay, 1 failed, 0 verify failed

Trying wibiti's version,

$ uncompyle2 md5.pyc         
...
#Embedded file name: md5.py
import warnings
warnings.warn('the md5 module is deprecated; use hashlib instead', DeprecationWarning, 2)
from hashlib import md5
new = md5
blocksize = 1
digest_size = 16
+++ okay decompyling md5.pyc 
# decompiled 1 files: 1 okay, 0 failed, 0 verify failed

URL for the failing file, https://dl.dropboxusercontent.com/u/1522424/md5.pyc

Mysterie commented 11 years ago

Thank you for reporting this bug. I think all your .PYC file have the same problem ? I wasn't able to reproduce the bug. But I think it's a cast issue in my marshal module.

unpack('l' instead of unpack('i'

I've push the modification, tell me if it's fixed.

I'm working on a big code refactoring for handling python 3.X decompilation and I'll try to get ride of a big part of uncompyle2 (walker/spark) wich are slow.

kholia commented 11 years ago

commit a9f26fc963548e617c7721eca1a39263d47285d3 fixed the problem. thanks! :+1: