X Tutup
Skip to content

Commit 61535a0

Browse files
committed
<2.5 grammar customizations for imports and loops
1 parent 62e6081 commit 61535a0

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
]}
3838
ftp_url = None
3939
install_requires = ['spark-parser >= 1.4.0',
40-
'xdis >= 1.1.5']
40+
'xdis >= 1.1.6']
4141
license = 'MIT'
4242
mailing_list = 'python-debugger@googlegroups.com'
4343
modname = 'uncompyle6'

uncompyle6/parsers/parse24.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
1515
def p_misc24(self, args):
1616
'''
1717
# 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import
18-
importstmt ::= LOAD_CONST filler import_as
19-
importfrom ::= LOAD_CONST filler IMPORT_NAME importlist2 POP_TOP
18+
# keep positions similar to simplify semantic actions
19+
20+
importstmt ::= filler LOAD_CONST import_as
21+
importfrom ::= filler LOAD_CONST IMPORT_NAME importlist2 POP_TOP
22+
23+
importmultiple ::= filler LOAD_CONST import_as imports_cont
24+
import_cont ::= filler LOAD_CONST import_as_cont
25+
26+
# Python 2.5+ omits POP_TOP POP_BLOCK
27+
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_TOP POP_BLOCK COME_FROM
28+
29+
call_stmt ::= yield
2030
'''
2131

2232
class Python24ParserSingle(Python25Parser, PythonParserSingle):

uncompyle6/scanners/scanner2.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,12 @@ def build_stmt_indices(self):
330330
j = self.prev[s]
331331
while code[j] == self.opc.JA:
332332
j = self.prev[j]
333-
if code[j] == self.opc.LIST_APPEND: # list comprehension
334-
stmts.remove(s)
335-
continue
333+
try:
334+
if code[j] == self.opc.LIST_APPEND: # list comprehension
335+
stmts.remove(s)
336+
continue
337+
except:
338+
from trepan.api import debug; debug()
336339
elif code[s] == self.opc.POP_TOP and code[self.prev[s]] == self.opc.ROT_TWO:
337340
stmts.remove(s)
338341
continue

0 commit comments

Comments
 (0)
X Tutup