From a5e3d01dd32702137d5082662a54f8a19ae50f37 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 26 Nov 2017 08:05:38 -0500 Subject: [PATCH] Work around grammar remove rule bug... And reinstate source to a current 3.3 bug (which we don't detect). But at least it is noted for future work. --- pytest/test_grammar.py | 8 ++++++++ test/bytecode_3.2/05_while_true_break.pyc | Bin 0 -> 444 bytes test/bytecode_3.4/05_while_true_break.pyc | Bin 365 -> 365 bytes test/simple_source/bug22/01_kv.py | 3 +++ .../bug32/05_while_true_break.py | 18 ++++++++++++++++++ 5 files changed, 29 insertions(+) create mode 100644 test/bytecode_3.2/05_while_true_break.pyc create mode 100644 test/simple_source/bug22/01_kv.py create mode 100644 test/simple_source/bug32/05_while_true_break.py diff --git a/pytest/test_grammar.py b/pytest/test_grammar.py index 8523c054..57c3792d 100644 --- a/pytest/test_grammar.py +++ b/pytest/test_grammar.py @@ -20,6 +20,7 @@ def test_grammar(): unused_rhs = set(['build_list', 'call_function', 'mkfunc', 'mklambda', 'unpack',]) + expect_right_recursive = frozenset([('designList', ('designator', 'DUP_TOP', 'designList'))]) if PYTHON3: @@ -35,6 +36,13 @@ def test_grammar(): pass else: expect_lhs.add('kwarg') + + # FIXME: grammar remove_rule on + # kv3 ::= expr expr STORE_MAP + # doesn't currently work in grammar, so we have this extraneous kv3 around. + if 3.3 <= PYTHON_VERSION <= 3.4: + expect_lhs.add('kv3') + assert expect_lhs == set(lhs) assert unused_rhs == set(rhs) assert expect_right_recursive == right_recursive diff --git a/test/bytecode_3.2/05_while_true_break.pyc b/test/bytecode_3.2/05_while_true_break.pyc new file mode 100644 index 0000000000000000000000000000000000000000..241682bb796c518012162778eb3d6a2139709179 GIT binary patch literal 444 zcmbV{&q@O^5Qit5?N%0x_x1%A1zRfKL@FMIQuNl#vfYF>y6v|4LlyL-@8s+Gn-o#- zW|n-(e3N8mo8w+S`RvbY`ZWah6HM0w6wwFK92-FoMFLZEo(HciZZX|G@O($FM33?8 zyC8c*Dxo*{5qo<^N^&^c4LEiKQt5XLwUg0G-7#NCym;nIKu?Ly} diff --git a/test/simple_source/bug22/01_kv.py b/test/simple_source/bug22/01_kv.py new file mode 100644 index 00000000..c0d0ef97 --- /dev/null +++ b/test/simple_source/bug22/01_kv.py @@ -0,0 +1,3 @@ +# Test of building map via kv rules +aa = 'aa' +dict0 = {'a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','b': 1234,'d': aa,aa: aa} diff --git a/test/simple_source/bug32/05_while_true_break.py b/test/simple_source/bug32/05_while_true_break.py new file mode 100644 index 00000000..8fdeeeb4 --- /dev/null +++ b/test/simple_source/bug32/05_while_true_break.py @@ -0,0 +1,18 @@ +# From 3.4 mailbox.py +# Bug is not not getting control structure right +# specifically the 2nd elif not line +def _generate_toc(line): + while 1: + if line.startswith('2'): + line = 5 + while 1: + if line: + line = 6 + break + elif not line: + line = 7 + break + elif not line: + break + + return 1