From efa964f7c9b3db93aa711944eeee9fc89cf955ec Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 23 Apr 2019 19:12:12 -0400 Subject: [PATCH] del handling in 3.0 and add tests --- test/bytecode_2.6_run/04_and_del.pyc | Bin 0 -> 781 bytes test/bytecode_3.0_run/04_and_del.pyc | Bin 0 -> 801 bytes test/simple_source/bug30/04_and_del.py | 20 ++++++++++++++++++++ uncompyle6/parsers/parse30.py | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/bytecode_2.6_run/04_and_del.pyc create mode 100644 test/bytecode_3.0_run/04_and_del.pyc create mode 100644 test/simple_source/bug30/04_and_del.py 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 0000000000000000000000000000000000000000..c15128a11761663c8a6dd9e9f37690879656620c GIT binary patch literal 781 zcmb7>zfRjw7{$+LJ4tEOpu*5(Kx&uDOA{nu14OA<8DOY{Dn-GzTt`W+@pYsk!2*4X zz6CQw9|5uR2%UI>p6|vHX)A_Wy2tnXcl^7)_m8h${`&FrON8oa@V&=nZzwVF9XJ6J z?ggpfnhFd(w-2O5g%&H3ZBpgaNZ1Vw2f4=ZT%OrTMl)Os(xR zK_E^BFkAB~(b^rJV%UIryO`A80B^Qt?=}GzEo;v5!=mLM(;Xgs=>G#W^Q^o+ll?f< zTRY4s;GFhE*waC7+2=GI7mSnsWG_6L)=A19-3eqQRopO|8t56Z7r>7N{V|1D5a0abdWsCCB+N3BmGdU;lhV!skJ8Wr6<1u D)$x1& literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..06a2ddebf48c09cbb89cf15b4ff01e7364b40ff4 GIT binary patch literal 801 zcmb7>%}U%*6vzK3$;{MFogz}4SqMs@WYZZz7X`H_#jP6`1t|<;64EdqH%;b(1>N}Z z6265mVBf(P=nM2A`aekqLyHS9oWuG2=XY;*-z>lWbNB08fZAy>KA`3IbRlp9oB|PJ zK`gkY2gVN47Gy5C5{Nb(gf2o4v8y9YIs4pH17Q=fR}JbOQ}@|%$`u=`-h5h$oqsmM z7Eb(Eqz;5mk3;ilUugMnI^N+@aQ=u3!5p}N%8dc@0Aa#vkLct!?L}e#$I>F~5mkFf zED(yD9?Yjjmw4SCZ!&JdyssB^*2CJZgZ(n>lA*5JC{#bzRX6GaJ>Gxp{>N0xR$5<) zf8y)UJ5K0e^$q$~U!dPlG_f@JS}3Bb4CtFj_(*_LI2H zrQ%eIQ4yb2U?rs1gX5B`u4_AN9OikH%@Z>_$}*EZalRCGZ)!q2i9Q#w`jw^5x_pp< F`~?axe{28% literal 0 HcmV?d00001 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