You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Binary file not shown.
BIN
test/bytecode_2.7/09_whiletrue_bug.pyc
Normal file
BIN
test/bytecode_2.7/09_whiletrue_bug.pyc
Normal file
Binary file not shown.
@@ -1,9 +1,12 @@
|
|||||||
if args == ['-']:
|
if __file__ == ['-']:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
compile(filename, doraise=True)
|
compile(__file__, doraise=True)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
rv = 1
|
rv = 1
|
||||||
else:
|
else:
|
||||||
rv = 1
|
rv = 1
|
||||||
print(rv)
|
print(rv)
|
||||||
|
|
||||||
|
|
||||||
|
while 1:pass
|
||||||
|
@@ -72,7 +72,7 @@ class PythonParser(GenericASTBuilder):
|
|||||||
print("Instruction context:")
|
print("Instruction context:")
|
||||||
for i in range(start, finish):
|
for i in range(start, finish):
|
||||||
indent = ' ' if i != index else '-> '
|
indent = ' ' if i != index else '-> '
|
||||||
print("%s%s" % (indent, instructions[i].format()))
|
print("%s%s" % (indent, instructions[i]))
|
||||||
raise ParserError(err_token, err_token.offset)
|
raise ParserError(err_token, err_token.offset)
|
||||||
|
|
||||||
def typestring(self, token):
|
def typestring(self, token):
|
||||||
|
@@ -40,6 +40,11 @@ class Python2Parser(PythonParser):
|
|||||||
print_nl ::= PRINT_NEWLINE
|
print_nl ::= PRINT_NEWLINE
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
def p_stmt2(self, args):
|
||||||
|
"""
|
||||||
|
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
||||||
|
"""
|
||||||
|
|
||||||
def p_print_to(self, args):
|
def p_print_to(self, args):
|
||||||
'''
|
'''
|
||||||
stmt ::= print_to
|
stmt ::= print_to
|
||||||
|
@@ -157,6 +157,8 @@ class Python26Parser(Python2Parser):
|
|||||||
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop
|
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop
|
||||||
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop
|
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop
|
||||||
|
|
||||||
|
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM
|
||||||
|
|
||||||
# Common with 2.7
|
# Common with 2.7
|
||||||
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
||||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||||
|
@@ -61,6 +61,8 @@ class Python27Parser(Python2Parser):
|
|||||||
POP_BLOCK LOAD_CONST COME_FROM
|
POP_BLOCK LOAD_CONST COME_FROM
|
||||||
WITH_CLEANUP END_FINALLY
|
WITH_CLEANUP END_FINALLY
|
||||||
|
|
||||||
|
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
||||||
|
|
||||||
# Common with 2.6
|
# Common with 2.6
|
||||||
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
|
||||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||||
|
@@ -218,8 +218,19 @@ class Scanner2(scan.Scanner):
|
|||||||
# in arbitrary value 0.
|
# in arbitrary value 0.
|
||||||
customize[opname] = 0
|
customize[opname] = 0
|
||||||
elif op == self.opc.JUMP_ABSOLUTE:
|
elif op == self.opc.JUMP_ABSOLUTE:
|
||||||
|
# Further classify JUMP_ABSOLUTE into backward jumps
|
||||||
|
# which are used in loops, and "CONTINUE" jumps which
|
||||||
|
# may appear in a "continue" statement. The loop-type
|
||||||
|
# and continue-type jumps will help us classify loop
|
||||||
|
# boundaries The continue-type jumps help us get
|
||||||
|
# "continue" statements with would otherwise be turned
|
||||||
|
# into a "pass" statement because JUMPs are sometimes
|
||||||
|
# ignored in rules as just boundary overhead. In
|
||||||
|
# comprehensions we might sometimes classify JUMP_BACK
|
||||||
|
# as CONTINUE, but that's okay since we add a grammar
|
||||||
|
# rule for that.
|
||||||
target = self.get_target(offset)
|
target = self.get_target(offset)
|
||||||
if target < offset:
|
if target <= offset:
|
||||||
if (offset in self.stmts
|
if (offset in self.stmts
|
||||||
and self.code[offset+3] not in (self.opc.END_FINALLY,
|
and self.code[offset+3] not in (self.opc.END_FINALLY,
|
||||||
self.opc.POP_BLOCK)
|
self.opc.POP_BLOCK)
|
||||||
|
@@ -259,7 +259,7 @@ class Scanner3(scan.Scanner):
|
|||||||
argval = (before_args, after_args)
|
argval = (before_args, after_args)
|
||||||
opname = '%s_%d+%d' % (opname, before_args, after_args)
|
opname = '%s_%d+%d' % (opname, before_args, after_args)
|
||||||
elif op == self.opc.JUMP_ABSOLUTE:
|
elif op == self.opc.JUMP_ABSOLUTE:
|
||||||
# Further classifhy JUMP_ABSOLUTE into backward jumps
|
# Further classify JUMP_ABSOLUTE into backward jumps
|
||||||
# which are used in loops, and "CONTINUE" jumps which
|
# which are used in loops, and "CONTINUE" jumps which
|
||||||
# may appear in a "continue" statement. The loop-type
|
# may appear in a "continue" statement. The loop-type
|
||||||
# and continue-type jumps will help us classify loop
|
# and continue-type jumps will help us classify loop
|
||||||
|
@@ -431,7 +431,7 @@ class ParserError(python_parser.ParserError):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
lines = ['--- This code section failed: ---']
|
lines = ['--- This code section failed: ---']
|
||||||
lines.extend([i.format() for i in self.tokens])
|
lines.extend([str(i) for i in self.tokens])
|
||||||
lines.extend( ['', str(self.error)] )
|
lines.extend( ['', str(self.error)] )
|
||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user