You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Start Python 2.1 bytecode decompile
This commit is contained in:
@@ -564,14 +564,18 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
TABLE_DIRECT.update({
|
||||
'tryfinallystmt': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', 1, 4 )
|
||||
})
|
||||
###########################
|
||||
# Import style for 2.0-2.3
|
||||
###########################
|
||||
TABLE_DIRECT.update({
|
||||
'importstmt20': ( '%|import %c\n', 1),
|
||||
'importstar20': ( '%|from %[1]{pattr} import *\n', ),
|
||||
'importfrom20': ( '%|from %[1]{pattr} import %c\n', 2 ),
|
||||
'importlist20': ( '%C', (0, maxint, ', ') ),
|
||||
if version == 2.1:
|
||||
###########################
|
||||
# Import style for 2.0-2.3
|
||||
###########################
|
||||
TABLE_DIRECT.update({
|
||||
'importstmt2': ( '%|import %c\n', 1),
|
||||
'import_as_cont': ( '%|import %c as %c\n', 1, 2),
|
||||
'importstar2': ( '%|from %[1]{pattr} import *\n', ),
|
||||
'importfrom2': ( '%|from %[1]{pattr} import %c\n', 2 ),
|
||||
'importlist2': ( '%C', (0, maxint, ', ') ),
|
||||
'IMPORT_NAME': ( '%{pattr}', ),
|
||||
'IMPORT_NAME_CONT': ( '%{pattr}', ),
|
||||
})
|
||||
|
||||
elif version >= 2.5:
|
||||
@@ -1055,13 +1059,17 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.prune()
|
||||
|
||||
def n_import_as(self, node):
|
||||
iname = node[0].pattr
|
||||
if self.version == 2.1 and node == 'import_as_cont':
|
||||
self.write("\n", self.indent, "import ")
|
||||
iname = node[1].pattr if node[0] == 'LOAD_CONST' else node[0].pattr
|
||||
assert node[-1][-1].type.startswith('STORE_')
|
||||
sname = node[-1][-1].pattr # assume one of STORE_.... here
|
||||
if iname == sname or iname.startswith(sname + '.'):
|
||||
if iname and iname == sname or iname.startswith(sname + '.'):
|
||||
self.write(iname)
|
||||
else:
|
||||
self.write(iname, ' as ', sname)
|
||||
if self.version == 2.1 and node == 'import_as_cont':
|
||||
self.write("\n")
|
||||
self.prune() # stop recursing
|
||||
|
||||
n_import_as_cont = n_import_as
|
||||
@@ -1794,7 +1802,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
"""
|
||||
|
||||
# self.println("----> ", startnode.type)
|
||||
|
||||
fmt = entry[0]
|
||||
arg = 1
|
||||
i = 0
|
||||
|
Reference in New Issue
Block a user