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

georg.brandl python-checkins at python.org
Tue May 30 09:34:46 CEST 2006


Author: georg.brandl
Date: Tue May 30 09:34:45 2006
New Revision: 46553

Modified:
   python/trunk/Lib/test/test_exceptions.py
   python/trunk/Objects/exceptions.c
Log:
Disallow keyword args for exceptions.



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 09:34:45 2006
@@ -296,3 +296,10 @@
                         ( 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")

Modified: python/trunk/Objects/exceptions.c
==============================================================================
--- python/trunk/Objects/exceptions.c	(original)
+++ python/trunk/Objects/exceptions.c	Tue May 30 09:34:45 2006
@@ -32,6 +32,9 @@
 {
     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;


More information about the Python-checkins mailing list