This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sbt
Recipients alexandre.vassalotti, belopolsky, bpb, brett.cannon, ehuss, facundobatista, fmitha, georg.brandl, gvanrossum, jafo, jaraco, jarpa, kylev, loewis, lukasz.langa, nnorwitz, pitrou, sbt, taleinat, tseaver, vstinner, zbysz, zseil
Date 2012-07-24.21:43:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1343166218.85.0.0504560172436.issue1692335@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2012-07-24 21:43:39sbtsetrecipients: + 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:38sbtsetmessageid: <1343166218.85.0.0504560172436.issue1692335@psf.upfronthosting.co.za>
2012-07-24 21:43:37sbtlinkissue1692335 messages
2012-07-24 21:43:37sbtcreate