[Python-3000-checkins] r64626 - in python/branches/py3k: Lib/test/test_syntax.py Python/ast.c

benjamin.peterson python-3000-checkins at python.org
Tue Jul 1 22:03:27 CEST 2008


Author: benjamin.peterson
Date: Tue Jul  1 22:03:27 2008
New Revision: 64626

Log:
Merged revisions 64622 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r64622 | benjamin.peterson | 2008-07-01 14:34:52 -0500 (Tue, 01 Jul 2008) | 1 line
  
  #3219 repeated keyword arguments aren't allowed in function calls anymore
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/test/test_syntax.py
   python/branches/py3k/Python/ast.c

Modified: python/branches/py3k/Lib/test/test_syntax.py
==============================================================================
--- python/branches/py3k/Lib/test/test_syntax.py	(original)
+++ python/branches/py3k/Lib/test/test_syntax.py	Tue Jul  1 22:03:27 2008
@@ -470,6 +470,12 @@
      ...
    SyntaxError: invalid syntax
 
+
+>>> f(a=23, a=234)
+Traceback (most recent call last):
+   ...
+SyntaxError: keyword argument repeated
+
 """
 
 import re

Modified: python/branches/py3k/Python/ast.c
==============================================================================
--- python/branches/py3k/Python/ast.c	(original)
+++ python/branches/py3k/Python/ast.c	Tue Jul  1 22:03:27 2008
@@ -1968,7 +1968,8 @@
             }
             else {
                 keyword_ty kw;
-                identifier key;
+                identifier key, tmp;
+                int k;
 
                 /* CHILD(ch, 0) is test, but must be an identifier? */ 
                 e = ast_for_expr(c, CHILD(ch, 0));
@@ -1989,6 +1990,13 @@
 		  return NULL;
 		}
                 key = e->v.Name.id;
+                for (k = 0; k < nkeywords; k++) {
+                    tmp = ((keyword_ty)asdl_seq_GET(keywords, k))->arg;
+                    if (!PyUnicode_Compare(tmp, key)) {
+                        ast_error(CHILD(ch, 0), "keyword argument repeated");
+                        return NULL;
+                    }
+                }
                 e = ast_for_expr(c, CHILD(ch, 2));
                 if (!e)
                     return NULL;


More information about the Python-3000-checkins mailing list