[Python-checkins] python/dist/src/Python getargs.c,2.105,2.106

birkenfeld@users.sourceforge.net birkenfeld at users.sourceforge.net
Fri Aug 26 08:42:40 CEST 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18370/Python

Modified Files:
	getargs.c 
Log Message:
Disallow keyword arguments for type constructors that don't use them.
(fixes bug #1119418)



Index: getargs.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v
retrieving revision 2.105
retrieving revision 2.106
diff -u -d -r2.105 -r2.106
--- getargs.c	30 Mar 2005 16:41:55 -0000	2.105
+++ getargs.c	26 Aug 2005 06:42:30 -0000	2.106
@@ -1595,3 +1595,29 @@
 	va_end(vargs);
 	return 1;
 }
+
+
+/* For type constructors that don't take keyword args
+ *
+ * Sets a TypeError and returns 0 if the kwds dict is 
+ * not emtpy, returns 1 otherwise
+ */
+int
+_PyArg_NoKeywords(char *funcname, PyObject *kw)
+{
+	if (kw == NULL)
+		return 1;
+	if (!PyDict_CheckExact(kw)) {
+		PyErr_BadInternalCall();
+		return 0;
+	}
+	if (PyDict_Size(kw) == 0)
+		return 1;
+	
+	PyErr_Format(PyExc_TypeError, "%s does not take keyword arguments", 
+			funcname);
+	return 0;
+}
+
+
+



More information about the Python-checkins mailing list