Start 3.3 positional and kw parameters

Semantic routines need more work.
This commit is contained in:
rocky 2016-06-19 19:18:45 -04:00
parent bd809dc08b
commit 8b50dda9ef
7 changed files with 22 additions and 4 deletions

View File

@ -0,0 +1,10 @@
# Bug from 3.3 configparser.py
# Python 3.3 has in bytecode positional args after keyoard args
# Python 3.4+ has positional args before keyword args
def __init__(self, defaults=None, dict_type=_default_dict,
allow_no_value=False, *, delimiters=('=', ':'),
comment_prefixes=('#', ';'), inline_comment_prefixes=None,
strict=True, empty_lines_in_values=True,
default_section=DEFAULTSECT,
interpolation=_UNSET):
pass

View File

@ -58,7 +58,7 @@ class PythonParser(GenericASTBuilder):
return token.type
def nonterminal(self, nt, args):
collect = ('stmts', 'exprlist', 'kvlist', '_stmts', 'print_items')
collect = ('stmts', 'exprlist', 'kvlist', '_stmts', 'print_items', 'kwargs')
if nt in collect and len(args) > 1:
#

View File

@ -530,7 +530,14 @@ class Python3Parser(PythonParser):
rule = ('mklambda ::= %sLOAD_LAMBDA LOAD_CONST %s' %
('pos_arg '* args_pos, opname))
self.add_unique_rule(rule, opname, token.attr, customize)
if self.version > 3.2:
if self.version == 3.3:
# positional args cafter keyword args
rule = ('mkfunc ::= kwargs %s%s %s' %
('pos_arg ' * args_pos,
'LOAD_CONST ' * 2,
opname))
elif self.version > 3.3:
# positional args before keyword args
rule = ('mkfunc ::= %skwargs %s %s' %
('pos_arg ' * args_pos,
'LOAD_CONST ' * 2,

View File

@ -1688,8 +1688,9 @@ class SourceWalker(GenericASTTraversal, object):
pass
if default:
maybe_show_ast_param_default(self.showast, name, default)
result = '%s=%s' % (name, self.traverse(default, indent='') )
value = self.traverse(default, indent='')
maybe_show_ast_param_default(self.showast, name, value)
result = '%s=%s' % (name, value)
if result[-2:] == '= ': # default was 'LOAD_CONST None'
result += 'None'
return result