diff --git a/test/bytecode_2.6_run/04_and_del.pyc b/test/bytecode_2.6_run/04_and_del.pyc new file mode 100644 index 00000000..c15128a1 Binary files /dev/null and b/test/bytecode_2.6_run/04_and_del.pyc differ diff --git a/test/bytecode_3.0_run/04_and_del.pyc b/test/bytecode_3.0_run/04_and_del.pyc new file mode 100644 index 00000000..06a2ddeb Binary files /dev/null and b/test/bytecode_3.0_run/04_and_del.pyc differ diff --git a/test/simple_source/bug30/04_and_del.py b/test/simple_source/bug30/04_and_del.py new file mode 100644 index 00000000..acc13be6 --- /dev/null +++ b/test/simple_source/bug30/04_and_del.py @@ -0,0 +1,20 @@ +# From 2.5.6 osxemxpath.py +# Bug is in getting "and" and "del" correct +def normpath(comps): + i = 0 + while i < len(comps): + if comps[i] == '.': + del comps[i] + elif comps[i] == '..' and i > 0 and comps[i-1] not in ('', '..'): + del comps[i-1:i+1] + i = i - 1 + elif comps[i] == '' and i > 0 and comps[i-1] != '': + del comps[i] + else: + i = i + 1 + return comps + +assert normpath(['.']) == [] +assert normpath(['a', 'b', '..']) == ['a'] +assert normpath(['a', 'b', '', 'c']) == ['a', 'b', 'c'] +assert normpath(['a', 'b', '.', '', 'c', '..']) == ['a', 'b'] diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py index 327849a0..e423cde2 100644 --- a/uncompyle6/parsers/parse30.py +++ b/uncompyle6/parsers/parse30.py @@ -31,7 +31,7 @@ class Python30Parser(Python31Parser): _ifstmts_jump ::= c_stmts COME_FROM POP_TOP # Used to keep index order the same in semantic actions - jb_pop_top ::= JUMP_BACK COME_FROM POP_TOP + jb_pop_top ::= JUMP_BACK _come_froms POP_TOP while1stmt ::= SETUP_LOOP l_stmts COME_FROM_LOOP whileelsestmt ::= SETUP_LOOP testexpr l_stmts