You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
<2.5 grammar customizations for imports and loops
This commit is contained in:
@@ -37,7 +37,7 @@ entry_points={
|
||||
]}
|
||||
ftp_url = None
|
||||
install_requires = ['spark-parser >= 1.4.0',
|
||||
'xdis >= 1.1.5']
|
||||
'xdis >= 1.1.6']
|
||||
license = 'MIT'
|
||||
mailing_list = 'python-debugger@googlegroups.com'
|
||||
modname = 'uncompyle6'
|
||||
|
@@ -15,8 +15,18 @@ class Python24Parser(Python25Parser):
|
||||
def p_misc24(self, args):
|
||||
'''
|
||||
# 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import
|
||||
importstmt ::= LOAD_CONST filler import_as
|
||||
importfrom ::= LOAD_CONST filler IMPORT_NAME importlist2 POP_TOP
|
||||
# keep positions similar to simplify semantic actions
|
||||
|
||||
importstmt ::= filler LOAD_CONST import_as
|
||||
importfrom ::= filler LOAD_CONST IMPORT_NAME importlist2 POP_TOP
|
||||
|
||||
importmultiple ::= filler LOAD_CONST import_as imports_cont
|
||||
import_cont ::= filler LOAD_CONST import_as_cont
|
||||
|
||||
# Python 2.5+ omits POP_TOP POP_BLOCK
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_TOP POP_BLOCK COME_FROM
|
||||
|
||||
call_stmt ::= yield
|
||||
'''
|
||||
|
||||
class Python24ParserSingle(Python25Parser, PythonParserSingle):
|
||||
|
@@ -330,9 +330,12 @@ class Scanner2(scan.Scanner):
|
||||
j = self.prev[s]
|
||||
while code[j] == self.opc.JA:
|
||||
j = self.prev[j]
|
||||
if code[j] == self.opc.LIST_APPEND: # list comprehension
|
||||
stmts.remove(s)
|
||||
continue
|
||||
try:
|
||||
if code[j] == self.opc.LIST_APPEND: # list comprehension
|
||||
stmts.remove(s)
|
||||
continue
|
||||
except:
|
||||
from trepan.api import debug; debug()
|
||||
elif code[s] == self.opc.POP_TOP and code[self.prev[s]] == self.opc.ROT_TWO:
|
||||
stmts.remove(s)
|
||||
continue
|
||||
|
Reference in New Issue
Block a user