You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
More 3.0 grammar fixes...
3.0 is such as snowflake
This commit is contained in:
BIN
test/bytecode_3.0/03_pop_top.pyc
Normal file
BIN
test/bytecode_3.0/03_pop_top.pyc
Normal file
Binary file not shown.
20
test/simple_source/bug30/03_pop_top.py
Normal file
20
test/simple_source/bug30/03_pop_top.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# From 3.0.1 __dummy_thread.py
|
||||||
|
# bug was handling else:
|
||||||
|
def interrupt_main():
|
||||||
|
"""Set _interrupt flag to True to have start_new_thread raise
|
||||||
|
KeyboardInterrupt upon exiting."""
|
||||||
|
if _main:
|
||||||
|
raise KeyboardInterrupt
|
||||||
|
else:
|
||||||
|
global _interrupt
|
||||||
|
_interrupt = True
|
||||||
|
|
||||||
|
# From 3.0.1 ast.py bug was mangling prototype
|
||||||
|
# def parse(expr, filename='<unknown>', mode='exec'):
|
||||||
|
|
||||||
|
# From 3.0.1 bisect
|
||||||
|
def bisect_left(a, x, lo=0, hi=None):
|
||||||
|
while lo:
|
||||||
|
if a[mid] < x: lo = mid+1
|
||||||
|
else: hi = mid
|
||||||
|
return lo
|
@@ -20,6 +20,8 @@ class Python30Parser(Python31Parser):
|
|||||||
|
|
||||||
# In many ways Python 3.0 code generation is more like Python 2.6 than
|
# In many ways Python 3.0 code generation is more like Python 2.6 than
|
||||||
# it is 2.7 or 3.1. So we have a number of 2.6ish (and before) rules below
|
# it is 2.7 or 3.1. So we have a number of 2.6ish (and before) rules below
|
||||||
|
# Specifically POP_TOP is more prevelant since there is no POP_JUMP_IF_...
|
||||||
|
# instructions
|
||||||
|
|
||||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms POP_TOP COME_FROM
|
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms POP_TOP COME_FROM
|
||||||
|
|
||||||
@@ -54,6 +56,8 @@ class Python30Parser(Python31Parser):
|
|||||||
comp_iter ::= expr expr SET_ADD
|
comp_iter ::= expr expr SET_ADD
|
||||||
comp_iter ::= expr expr LIST_APPEND
|
comp_iter ::= expr expr LIST_APPEND
|
||||||
|
|
||||||
|
jump_forward_else ::= JUMP_FORWARD POP_TOP
|
||||||
|
|
||||||
# In many ways 3.0 is like 2.6. The below rules in fact are the same or similar.
|
# In many ways 3.0 is like 2.6. The below rules in fact are the same or similar.
|
||||||
|
|
||||||
jmp_true ::= JUMP_IF_TRUE POP_TOP
|
jmp_true ::= JUMP_IF_TRUE POP_TOP
|
||||||
@@ -63,6 +67,8 @@ class Python30Parser(Python31Parser):
|
|||||||
POP_TOP END_FINALLY come_froms
|
POP_TOP END_FINALLY come_froms
|
||||||
return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP
|
return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP
|
||||||
and ::= expr JUMP_IF_FALSE POP_TOP expr COME_FROM
|
and ::= expr JUMP_IF_FALSE POP_TOP expr COME_FROM
|
||||||
|
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt
|
||||||
|
JUMP_BACK POP_TOP POP_BLOCK COME_FROM_LOOP
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def customize_grammar_rules(self, tokens, customize):
|
def customize_grammar_rules(self, tokens, customize):
|
||||||
|
Reference in New Issue
Block a user