]> granicus.if.org Git - python/commitdiff
Disallow keyword args for exceptions.
authorGeorg Brandl <georg@python.org>
Tue, 30 May 2006 07:34:45 +0000 (07:34 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 30 May 2006 07:34:45 +0000 (07:34 +0000)
Lib/test/test_exceptions.py
Objects/exceptions.c

index b4a766e89b62736940bc04fc23248e2db2b53cbb..20e76b91ba8fbf1fe7914873c11210970ec77d86 100644 (file)
@@ -296,3 +296,10 @@ for args in exceptionList:
                         ( repr(e), checkArgName,
                             repr(expected[checkArgName]),
                             repr(getattr(e, checkArgName)) ))
+
+try:
+    BaseException(a=1)
+except TypeErrror:
+    pass
+else:
+    raise TestFailed("BaseException shouldn't take keyword args")
index 16ba5e56c269111802e2f27a33fd63d24d7c097f..28fb0c14e88bcc56aaba9adee6d3097c8cbbdb66 100644 (file)
@@ -32,6 +32,9 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     PyBaseExceptionObject *self;
 
+    if (!_PyArg_NoKeywords("BaseException", kwds))
+        return NULL;
+
     self = (PyBaseExceptionObject *)type->tp_alloc(type, 0);
     /* the dict is created on the fly in PyObject_GenericSetAttr */
     self->message = self->dict = NULL;