Python 3 bugs ...

- Was using "while 1 .. else" improperly
- docstring indent bug: was indenting docstring improperly
This commit is contained in:
rocky
2016-11-13 10:08:41 -05:00
parent 3b9e48a3b6
commit a81ffe8963
3 changed files with 2 additions and 6 deletions

View File

@@ -338,10 +338,8 @@ class Python3Parser(PythonParser):
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
else_suite COME_FROM_LOOP
# FIXME: This gets confused with if/else in a loop. But while/else in Python
# is probably pretty rare.
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
else_suite COME_FROM_LOOP
else_suite
whileelselaststmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
else_suitec COME_FROM_LOOP

View File

@@ -26,8 +26,6 @@ class Python30Parser(Python3Parser):
# Used to keep index order the same in semantic actions
jb_pop_top ::= JUMP_BACK POP_TOP
# FIXME: Add COME_FROM designators
# This gets confused with while1elsestmt. But this is probably more common
while1stmt ::= SETUP_LOOP l_stmts COME_FROM_LOOP
else_suitel ::= l_stmts COME_FROM_LOOP JUMP_BACK

View File

@@ -542,7 +542,7 @@ def make_function3(self, node, isLambda, nested=1, codeNode=None):
if len(code.co_consts) > 0 and code.co_consts[0] is not None and not isLambda: # ugly
# docstring exists, dump it
self.print_docstring(indent, code.co_consts[0])
self.print_docstring(self.indent, code.co_consts[0])
code._tokens = None # save memory
assert ast == 'stmts'