From 92d63ac598aac5147d71ff723356bb014a8aa04d Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 10 Jun 2018 05:26:00 -0400 Subject: [PATCH] More 3.0 grammar fixes... 3.0 is such as snowflake --- test/bytecode_3.0/03_pop_top.pyc | Bin 0 -> 728 bytes test/simple_source/bug30/03_pop_top.py | 20 ++++++++++++++++++++ uncompyle6/parsers/parse30.py | 6 ++++++ 3 files changed, 26 insertions(+) create mode 100644 test/bytecode_3.0/03_pop_top.pyc create mode 100644 test/simple_source/bug30/03_pop_top.py diff --git a/test/bytecode_3.0/03_pop_top.pyc b/test/bytecode_3.0/03_pop_top.pyc new file mode 100644 index 0000000000000000000000000000000000000000..04cd89b5e9e800d5c6401e1f38535f1d9656f847 GIT binary patch literal 728 zcmb7BO-lnY5S{F*)$Ip*60wK%Rxh^VMNmZWBtkDO2nsG~H@3m;X5Gzbh4v!-HU2mM zgEJ|#YA+hdn>S%TGH=c*)!^f^e&2_0$0vSCx2O}u05gC)A_8I`Vh?5>+SOM<>(h>+tmQ+GeCilPxf{wCbq*JT%95Wj}CUOv36Lxb{Y=`ni zg@u*5jZ*a**Fumn6Hx6q?3QBh$q@2h4H2Pds&>m z2*59iz}L+B+>;MmkFL}0l*srPCLWkW5ECcj-bBC?X;~vJ-5z$Q9z6TboBEF3QbMP} zRoa?&&|pArJJRu70)COmI7SXkj59<1@A=A<-J=EcZIq}-yG?FUApqe+N$fyPltp{K j;Z-S|)NPY0{8eW84afed^(M7FADI{vb>URz(YC5zufm$N literal 0 HcmV?d00001 diff --git a/test/simple_source/bug30/03_pop_top.py b/test/simple_source/bug30/03_pop_top.py new file mode 100644 index 00000000..cb613ba0 --- /dev/null +++ b/test/simple_source/bug30/03_pop_top.py @@ -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='', 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 diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py index 4c73f616..ef369566 100644 --- a/uncompyle6/parsers/parse30.py +++ b/uncompyle6/parsers/parse30.py @@ -20,6 +20,8 @@ class Python30Parser(Python31Parser): # 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 + # 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 @@ -54,6 +56,8 @@ class Python30Parser(Python31Parser): comp_iter ::= expr expr SET_ADD 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. jmp_true ::= JUMP_IF_TRUE POP_TOP @@ -63,6 +67,8 @@ class Python30Parser(Python31Parser): POP_TOP END_FINALLY come_froms return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP 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):