From: Georg Brandl Date: Tue, 30 May 2006 07:34:45 +0000 (+0000) Subject: Disallow keyword args for exceptions. X-Git-Tag: v2.5b1~336 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=861089fc49e17bc3d192e01f19641d9e01e0fa03;p=thirdparty%2FPython%2Fcpython.git Disallow keyword args for exceptions. --- diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index b4a766e89b62..20e76b91ba8f 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -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") diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 16ba5e56c269..28fb0c14e88b 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -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;