mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-27 15:10:55 +00:00
Start 3.3 positional and kw parameters
Semantic routines need more work.
This commit is contained in:
parent
bd809dc08b
commit
8b50dda9ef
10
test/simple_source/def/10_kw+pos_args-bug.py
Normal file
10
test/simple_source/def/10_kw+pos_args-bug.py
Normal 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
|
@ -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:
|
||||
#
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user