python/dist/src/Python getargs.c, 2.102.2.2, 2.102.2.3
![](https://secure.gravatar.com/avatar/cb8fcd8488593ab4d26d4770effab2a5.jpg?s=120&d=mm&r=g)
Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18531/Python Modified Files: Tag: release24-maint getargs.c Log Message: Disallow keyword arguments for type constructors that don't use them (fixes #1119418). Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.102.2.2 retrieving revision 2.102.2.3 diff -u -d -r2.102.2.2 -r2.102.2.3 --- getargs.c 3 Mar 2005 12:26:20 -0000 2.102.2.2 +++ getargs.c 26 Aug 2005 06:43:16 -0000 2.102.2.3 @@ -1594,3 +1594,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; +} + + +
participants (1)
-
birkenfeldīŧ users.sourceforge.net