mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 21:20:06 +00:00
del handling in 3.0 and add tests
This commit is contained in:
parent
5c58a4816f
commit
efa964f7c9
BIN
test/bytecode_2.6_run/04_and_del.pyc
Normal file
BIN
test/bytecode_2.6_run/04_and_del.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.0_run/04_and_del.pyc
Normal file
BIN
test/bytecode_3.0_run/04_and_del.pyc
Normal file
Binary file not shown.
20
test/simple_source/bug30/04_and_del.py
Normal file
20
test/simple_source/bug30/04_and_del.py
Normal 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']
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user