Mercurial > cpython-lru_cache-weakref
comparison Python/getargs.c @ 35449:1fdfd0130e28 legacy-trunk
Disallow keyword arguments for type constructors that don't use them.
(fixes bug #1119418)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Fri, 26 Aug 2005 06:42:30 +0000 |
| parents | 13d5caa1e9d0 |
| children | 9b7d117eb4bc |
comparison
equal
deleted
inserted
replaced
| 35447:0999290c6758 | 35449:1fdfd0130e28 |
|---|---|
| 1593 *o = PyTuple_GET_ITEM(args, i); | 1593 *o = PyTuple_GET_ITEM(args, i); |
| 1594 } | 1594 } |
| 1595 va_end(vargs); | 1595 va_end(vargs); |
| 1596 return 1; | 1596 return 1; |
| 1597 } | 1597 } |
| 1598 | |
| 1599 | |
| 1600 /* For type constructors that don't take keyword args | |
| 1601 * | |
| 1602 * Sets a TypeError and returns 0 if the kwds dict is | |
| 1603 * not emtpy, returns 1 otherwise | |
| 1604 */ | |
| 1605 int | |
| 1606 _PyArg_NoKeywords(char *funcname, PyObject *kw) | |
| 1607 { | |
| 1608 if (kw == NULL) | |
| 1609 return 1; | |
| 1610 if (!PyDict_CheckExact(kw)) { | |
| 1611 PyErr_BadInternalCall(); | |
| 1612 return 0; | |
| 1613 } | |
| 1614 if (PyDict_Size(kw) == 0) | |
| 1615 return 1; | |
| 1616 | |
| 1617 PyErr_Format(PyExc_TypeError, "%s does not take keyword arguments", | |
| 1618 funcname); | |
| 1619 return 0; | |
| 1620 } | |
| 1621 | |
| 1622 | |
| 1623 |
