del handling in 3.0 and add tests

This commit is contained in:
rocky 2019-04-23 19:12:12 -04:00
parent 5c58a4816f
commit efa964f7c9
4 changed files with 21 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -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']

View File

@ -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