[Python-checkins] r46555 - in python/trunk: Lib/test/test_exceptions.py Objects/exceptions.c

georg.brandl python-checkins at python.org
Tue May 30 10:17:01 CEST 2006


Author: georg.brandl
Date: Tue May 30 10:17:00 2006
New Revision: 46555

Modified:
   python/trunk/Lib/test/test_exceptions.py
   python/trunk/Objects/exceptions.c
Log:
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args



Modified: python/trunk/Lib/test/test_exceptions.py
==============================================================================
--- python/trunk/Lib/test/test_exceptions.py	(original)
+++ python/trunk/Lib/test/test_exceptions.py	Tue May 30 10:17:00 2006
@@ -299,7 +299,7 @@
 
 try:
     BaseException(a=1)
-except TypeErrror:
+except TypeError:
     pass
 else:
     raise TestFailed("BaseException shouldn't take keyword args")

Modified: python/trunk/Objects/exceptions.c
==============================================================================
--- python/trunk/Objects/exceptions.c	(original)
+++ python/trunk/Objects/exceptions.c	Tue May 30 10:17:00 2006
@@ -32,9 +32,6 @@
 {
     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;
@@ -57,6 +54,9 @@
 static int
 BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
 {
+    if (!_PyArg_NoKeywords(self->ob_type->tp_name, kwds))
+        return -1;
+
     Py_DECREF(self->args);
     self->args = args;
     Py_INCREF(self->args);


More information about the Python-checkins mailing list