ISTM the simplest approach would be to just set self->args in BaseException.__new__() (like in Georg's patch) but to ignore the possibility that the user might later set self.args to something stupid "wrong":
diff -r 51ac5f06dd04 Objects/exceptions.c
--- a/Objects/exceptions.c Tue Jul 24 03:45:39 2012 -0700
+++ b/Objects/exceptions.c Tue Jul 24 22:12:49 2012 +0100
@@ -44,12 +44,17 @@
self->traceback = self->cause = self->context = NULL;
self->suppress_context = 0;
- self->args = PyTuple_New(0);
- if (!self->args) {
- Py_DECREF(self);
- return NULL;
+ if (!args) {
+ args = PyTuple_New(0);
+ if (!args) {
+ Py_DECREF(self);
+ return NULL;
+ }
+ } else {
+ Py_INCREF(args);
}
+ self->args = args;
return (PyObject *)self;
}
Certainly it will not work for all cases (like calling a base classes' __init__ with different arguments), but it does cover the *very* common case where __init__() is defined but does not call the base classes' __init__().
Such a patch is minimally invasive and, as far as I can see, would not break currently working code.
Would this be acceptable for a bugfix release?