[New-bugs-announce] [issue6844] BaseException DeprecationError raises inappropriately

Alan Isaac report at bugs.python.org
Sat Sep 5 18:24:54 CEST 2009


New submission from Alan Isaac <alan.isaac at gmail.com>:

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.

----------
components: Interpreter Core
messages: 92281
nosy: aisaac
severity: normal
status: open
title: BaseException DeprecationError raises inappropriately
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6844>
_______________________________________


More information about the New-bugs-announce mailing list