You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Handle Python 2.4 if true
This commit is contained in:
BIN
test/bytecode_2.4/03_iftrue.pyc
Normal file
BIN
test/bytecode_2.4/03_iftrue.pyc
Normal file
Binary file not shown.
@@ -32,6 +32,11 @@ class Python24Parser(Python25Parser):
|
||||
importmultiple ::= filler LOAD_CONST alias imports_cont
|
||||
import_cont ::= filler LOAD_CONST alias
|
||||
|
||||
# Handle "if true else: ..." in Python 2.4
|
||||
stmt ::= iftrue_stmt24
|
||||
iftrue_stmt24 ::= _ifstmts_jump24 suite_stmts COME_FROM
|
||||
_ifstmts_jump24 ::= c_stmts_opt JUMP_FORWARD POP_TOP
|
||||
|
||||
# Python 2.5+ omits POP_TOP POP_BLOCK
|
||||
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_TOP POP_BLOCK COME_FROM
|
||||
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_TOP POP_BLOCK
|
||||
|
@@ -43,10 +43,19 @@ def customize_for_version(self, is_pypy, version):
|
||||
'assert': ( '%|assert %c\n' , 0 ),
|
||||
'assert2': ( '%|assert %c, %c\n' , 0, 3 ),
|
||||
'try_except': ( '%|try:\n%+%c%-%c\n\n', 1, 3 ),
|
||||
'assign2': ( '%|%c, %c = %c, %c\n', 3, 4, 0, 1 ),
|
||||
'assign3': ( '%|%c, %c, %c = %c, %c, %c\n', 5, 6, 7, 0, 1, 2 ),
|
||||
'assign2': ( '%|%c, %c = %c, %c\n',
|
||||
3, 4, 0, 1 ),
|
||||
'assign3': ( '%|%c, %c, %c = %c, %c, %c\n',
|
||||
5, 6, 7, 0, 1, 2 ),
|
||||
})
|
||||
if version < 3.0:
|
||||
if version == 2.4:
|
||||
def n_iftrue_stmt24(node):
|
||||
self.template_engine(('%|%c', 0), node)
|
||||
self.default(node)
|
||||
self.prune()
|
||||
self.n_iftrue_stmt24 = n_iftrue_stmt24
|
||||
|
||||
TABLE_R.update({
|
||||
'STORE_SLICE+0': ( '%c[:]', 0 ),
|
||||
'STORE_SLICE+1': ( '%c[%p:]', 0, (1, -1) ),
|
||||
@@ -62,7 +71,7 @@ def customize_for_version(self, is_pypy, version):
|
||||
})
|
||||
|
||||
# exec as a built-in statement is only in Python 2.x
|
||||
def n_exec_stmt(self, node):
|
||||
def n_exec_stmt(node):
|
||||
"""
|
||||
exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT
|
||||
exec_stmt ::= expr exprlist EXEC_STMT
|
||||
|
Reference in New Issue
Block a user