3.5 *() arg without further args

This commit is contained in:
rocky
2018-03-25 22:24:32 -04:00
parent 0b622a0ad8
commit cfb4ad625f
4 changed files with 15 additions and 3 deletions

View File

@@ -21,3 +21,10 @@ def Time2Internaldate(date_time):
return datetime(*date_time[:6], tzinfo=timezone(delta))
assert Time2Internaldate(time.localtime())
# From 3.5.5 tkinter/dialog.py
def test_varargs0_ext(self):
try:
{}.__contains__(*())
except TypeError:
pass

View File

@@ -210,7 +210,6 @@ class Python35Parser(Python34Parser):
self.add_unique_rule(rule, token.kind, uniq_param, customize)
self.add_unique_rule('expr ::= async_call', token.kind, uniq_param, customize)
uniq_param = args_kw + args_pos
if opname.startswith('CALL_FUNCTION_VAR'):
# Python 3.5 changes the stack position of *args. KW args come
# after *args.
@@ -226,7 +225,10 @@ class Python35Parser(Python34Parser):
rule = ('call ::= expr expr ' +
('pos_arg ' * args_pos) +
('kwarg ' * args_kw) + kw + token.kind)
self.add_unique_rule(rule, token.kind, uniq_param, customize)
# Note: semantic actions make use of the fact of wheter "args_pos"
# zero or not in creating a template rule.
self.add_unique_rule(rule, token.kind, args_pos, customize)
else:
super(Python35Parser, self).custom_classfunc_rule(opname, token, customize,
seen_LOAD_BUILD_CLASS,

View File

@@ -313,7 +313,10 @@ def customize_for_version(self, is_pypy, version):
template = ('*%P)', (0, len(args_node)-1, ', *', 100))
self.template_engine(template, args_node)
else:
template = ('*%c, %C)', 1, (2, -1, ', '))
if len(node) > 3:
template = ('*%c, %C)', 1, (2, -1, ', '))
else:
template = ('*%c)', 1)
self.template_engine(template, node)
self.prune()