Fix 3.1 and 3.2 named and kwargs parsing..

Improve 3.4 coverage and note a 3.5 while bug
This commit is contained in:
rocky
2017-12-07 15:50:27 -05:00
parent 41bfa3fc01
commit 88fbb691d8
7 changed files with 37 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,28 @@
# From Python 3.4 asynchat.py
# Tests presence or absense of
# SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM_LOOP
def initiate_send(self, num_sent, first):
while self.producer_fifo and self.connected:
try:
5
except OSError:
return
if num_sent:
if first:
self.producer_fifo = '6'
else:
del self.producer_fifo[0]
return
# FIXME: this causes a parse error:
# def initiate_send(self):
# while self.producer_fifo and self.connected:
# try:
# 6
# except OSError:
# return
# return

View File

@@ -815,8 +815,8 @@ class Python3Parser(PythonParser):
# Note order of kwargs and pos args changed between 3.3-3.4 # Note order of kwargs and pos args changed between 3.3-3.4
if self.version <= 3.2: if self.version <= 3.2:
rule = ('mkfunc ::= %sload_closure LOAD_CONST kwargs %s' rule = ('mkfunc ::= %s%sload_closure LOAD_CONST kwargs %s'
% (kwargs_str, ('expr ' * args_pos, opname))) % (kwargs_str, 'expr ' * args_pos, opname))
elif self.version == 3.3: elif self.version == 3.3:
rule = ('mkfunc ::= %s%sload_closure LOAD_CONST LOAD_CONST %s' rule = ('mkfunc ::= %s%sload_closure LOAD_CONST LOAD_CONST %s'
% (kwargs_str, 'expr ' * args_pos, opname)) % (kwargs_str, 'expr ' * args_pos, opname))
@@ -899,7 +899,12 @@ class Python3Parser(PythonParser):
opname)) opname))
self.add_make_function_rule(rule_pat, opname, token.attr, customize) self.add_make_function_rule(rule_pat, opname, token.attr, customize)
if self.version == 3.3: if self.version < 3.3:
# positional args after keyword args
rule = ('mkfunc ::= kwargs %s%s %s' %
('pos_arg ' * args_pos, 'LOAD_CONST ',
opname))
elif self.version == 3.3:
# positional args after keyword args # positional args after keyword args
rule = ('mkfunc ::= kwargs %s%s %s' % rule = ('mkfunc ::= kwargs %s%s %s' %
('pos_arg ' * args_pos, 'LOAD_CONST '*2, ('pos_arg ' * args_pos, 'LOAD_CONST '*2,

View File

@@ -25,6 +25,7 @@ class Python35Parser(Python34Parser):
while1stmt ::= SETUP_LOOP l_stmts POP_BLOCK COME_FROM_LOOP while1stmt ::= SETUP_LOOP l_stmts POP_BLOCK COME_FROM_LOOP
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
POP_BLOCK else_suite COME_FROM_LOOP POP_BLOCK else_suite COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM_LOOP
# The following rule is for Python 3.5+ where we can have stuff like # The following rule is for Python 3.5+ where we can have stuff like
# while .. # while ..