mirror of
https://github.com/python/cpython.git
synced 2025-07-30 14:44:10 +00:00
Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler package.
This commit is contained in:
parent
23d9d45482
commit
1bb6230930
3 changed files with 11 additions and 7 deletions
|
@ -841,17 +841,15 @@ class Transformer:
|
|||
names.append(self.com_fpdef(node))
|
||||
|
||||
i = i + 1
|
||||
if i >= len(nodelist):
|
||||
break
|
||||
|
||||
if nodelist[i][0] == token.EQUAL:
|
||||
if i < len(nodelist) and nodelist[i][0] == token.EQUAL:
|
||||
defaults.append(self.com_node(nodelist[i + 1]))
|
||||
i = i + 2
|
||||
elif len(defaults):
|
||||
# XXX This should be a syntax error.
|
||||
# Treat "(a=1, b)" as "(a=1, b=None)"
|
||||
defaults.append(Const(None))
|
||||
# we have already seen an argument with default, but here
|
||||
# came one without
|
||||
raise SyntaxError, "non-default argument follows default argument"
|
||||
|
||||
# skip the comma
|
||||
i = i + 1
|
||||
|
||||
return names, defaults, flags
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue