Message166332
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? |
|
Date |
User |
Action |
Args |
2012-07-24 21:43:39 | sbt | set | recipients:
+ sbt, gvanrossum, loewis, nnorwitz, brett.cannon, georg.brandl, facundobatista, jafo, ehuss, tseaver, jaraco, belopolsky, zseil, fmitha, pitrou, vstinner, taleinat, alexandre.vassalotti, jarpa, bpb, zbysz, kylev, lukasz.langa |
2012-07-24 21:43:38 | sbt | set | messageid: <1343166218.85.0.0504560172436.issue1692335@psf.upfronthosting.co.za> |
2012-07-24 21:43:37 | sbt | link | issue1692335 messages |
2012-07-24 21:43:37 | sbt | create | |
|