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 aisaac
Recipients aisaac
Date 2009-09-05.16:24:52
SpamBayes Score 9.074386e-11
Marked as misclassified No
Message-id <1252167894.27.0.660137723145.issue6844@psf.upfronthosting.co.za>
In-reply-to
Content
In Python 2.6 if I subclass Exception and intialize my instances with a
`message` attribute, I get a DeprecationError via BaseException.

Of course there is no problem in Py3, because adding a `message`
attribute to instances of a subclass is in fact **not** a problem and
will **not** be disallowed.  I.e., the DeprecationError is raised
incorrectly in Python 2.6.

I am not sure how to raise a DeprecationError *only* in the correct
cases, but certainly the current behavior can be much improved.  As a
crude example, if the `args` passed to BaseException has length 0, then
a flag could be set not to raise this DeprecationError.  Even if not
perfect, this would be **much** better than the current behavior, since
it is common practice not to pass the subclass's initialization
arguments on to Exception.__init__.

This behavior can be expected to affect entire libraries and therefore
should be fixed.  (Eg., it affects docutils.)  I.e., "change the name of
your variable" is the wrong answer to this bug report.
History
Date User Action Args
2009-09-05 16:24:54aisaacsetrecipients: + aisaac
2009-09-05 16:24:54aisaacsetmessageid: <1252167894.27.0.660137723145.issue6844@psf.upfronthosting.co.za>
2009-09-05 16:24:53aisaaclinkissue6844 messages
2009-09-05 16:24:52aisaaccreate