summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/transformer.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-05-03 18:18:32 (GMT)
committerGeorg Brandl <georg@python.org>2006-05-03 18:18:32 (GMT)
commit1bb62309307fa8a199ef5a53ae0f775dfff4fa3f (patch)
tree55a7f8fafe7e79ea665c2cddd3e0752bef841150 /Lib/compiler/transformer.py
parent23d9d45482fc3ed67c26418d20f31bfb201db4dd (diff)
downloadcpython-1bb62309307fa8a199ef5a53ae0f775dfff4fa3f.zip
cpython-1bb62309307fa8a199ef5a53ae0f775dfff4fa3f.tar.gz
cpython-1bb62309307fa8a199ef5a53ae0f775dfff4fa3f.tar.bz2
Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler package.
Diffstat (limited to 'Lib/compiler/transformer.py')
-rw-r--r--Lib/compiler/transformer.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index 8225dfa..e1a9775 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -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