mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 21:20:06 +00:00
Fix marshal UTF8 bug
This commit is contained in:
parent
baaa7f81d0
commit
09b2adbbbd
@ -38,13 +38,10 @@ __all__ = ['uncompyle_file', 'main']
|
||||
def _load_file(filename):
|
||||
'''
|
||||
load a Python source file and compile it to byte-code
|
||||
|
||||
_load_module(filename: string): code_object
|
||||
|
||||
filename: name of file containing Python source code
|
||||
(normally a .py)
|
||||
code_object: code_object compiled from this source code
|
||||
|
||||
This function does NOT write any file!
|
||||
'''
|
||||
fp = open(filename, 'rb')
|
||||
@ -61,7 +58,6 @@ def _load_module(filename):
|
||||
'''
|
||||
load a module without importing it
|
||||
_load_module(filename: string): code_object
|
||||
|
||||
filename: name of file containing Python byte-code object
|
||||
(normally a .pyc)
|
||||
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
|
||||
#print version
|
||||
fp.read(4) # timestamp
|
||||
co = marshal.load(fp) #dis.marshalLoad(fp)
|
||||
co = dis.marshalLoad(fp)
|
||||
fp.close()
|
||||
return version, co
|
||||
|
||||
|
@ -254,7 +254,6 @@ def load(fp):
|
||||
n = unpack('l', fp.read(4))[0]
|
||||
if n == 0:
|
||||
return long(0)
|
||||
ratio = 2 #2 for 64bit 1 for 32bit
|
||||
size = abs(n);
|
||||
d = long(0)
|
||||
for j in range(0, size):
|
||||
@ -277,7 +276,8 @@ def load(fp):
|
||||
return interned
|
||||
elif marshalType == 'u':
|
||||
strsize = unpack('l', fp.read(4))[0]
|
||||
return unicode(fp.read(strsize))
|
||||
unicodestring = fp.read(strsize)
|
||||
return unicodestring.decode('utf-8')
|
||||
# collection type
|
||||
elif marshalType == '(':
|
||||
tuplesize = unpack('l', fp.read(4))[0]
|
||||
|
Loading…
Reference in New Issue
Block a user