You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
Fix marshal UTF8 bug
This commit is contained in:
@@ -38,13 +38,10 @@ __all__ = ['uncompyle_file', 'main']
|
|||||||
def _load_file(filename):
|
def _load_file(filename):
|
||||||
'''
|
'''
|
||||||
load a Python source file and compile it to byte-code
|
load a Python source file and compile it to byte-code
|
||||||
|
|
||||||
_load_module(filename: string): code_object
|
_load_module(filename: string): code_object
|
||||||
|
|
||||||
filename: name of file containing Python source code
|
filename: name of file containing Python source code
|
||||||
(normally a .py)
|
(normally a .py)
|
||||||
code_object: code_object compiled from this source code
|
code_object: code_object compiled from this source code
|
||||||
|
|
||||||
This function does NOT write any file!
|
This function does NOT write any file!
|
||||||
'''
|
'''
|
||||||
fp = open(filename, 'rb')
|
fp = open(filename, 'rb')
|
||||||
@@ -61,7 +58,6 @@ def _load_module(filename):
|
|||||||
'''
|
'''
|
||||||
load a module without importing it
|
load a module without importing it
|
||||||
_load_module(filename: string): code_object
|
_load_module(filename: string): code_object
|
||||||
|
|
||||||
filename: name of file containing Python byte-code object
|
filename: name of file containing Python byte-code object
|
||||||
(normally a .pyc)
|
(normally a .pyc)
|
||||||
code_object: code_object from this file
|
code_object: code_object from this file
|
||||||
@@ -77,7 +73,7 @@ def _load_module(filename):
|
|||||||
raise ImportError, "This is a Python %s file! Only Python 2.5 to 2.7 files are supported." % version
|
raise ImportError, "This is a Python %s file! Only Python 2.5 to 2.7 files are supported." % version
|
||||||
#print version
|
#print version
|
||||||
fp.read(4) # timestamp
|
fp.read(4) # timestamp
|
||||||
co = marshal.load(fp) #dis.marshalLoad(fp)
|
co = dis.marshalLoad(fp)
|
||||||
fp.close()
|
fp.close()
|
||||||
return version, co
|
return version, co
|
||||||
|
|
||||||
|
@@ -254,7 +254,6 @@ def load(fp):
|
|||||||
n = unpack('l', fp.read(4))[0]
|
n = unpack('l', fp.read(4))[0]
|
||||||
if n == 0:
|
if n == 0:
|
||||||
return long(0)
|
return long(0)
|
||||||
ratio = 2 #2 for 64bit 1 for 32bit
|
|
||||||
size = abs(n);
|
size = abs(n);
|
||||||
d = long(0)
|
d = long(0)
|
||||||
for j in range(0, size):
|
for j in range(0, size):
|
||||||
@@ -277,7 +276,8 @@ def load(fp):
|
|||||||
return interned
|
return interned
|
||||||
elif marshalType == 'u':
|
elif marshalType == 'u':
|
||||||
strsize = unpack('l', fp.read(4))[0]
|
strsize = unpack('l', fp.read(4))[0]
|
||||||
return unicode(fp.read(strsize))
|
unicodestring = fp.read(strsize)
|
||||||
|
return unicodestring.decode('utf-8')
|
||||||
# collection type
|
# collection type
|
||||||
elif marshalType == '(':
|
elif marshalType == '(':
|
||||||
tuplesize = unpack('l', fp.read(4))[0]
|
tuplesize = unpack('l', fp.read(4))[0]
|
||||||
|
Reference in New Issue
Block a user