Alan G Isaac wrote:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
class MyError(Exception):
... def __init__(self, message):
... Exception.__init__(self)
... self.message = message
...
e = MyError('msg')
__main__:4: DeprecationWarning: BaseException.message has been
deprecated as of Python 2.6
So? Why would that mean I cannot add such an attribute
to derived classes?
It does not mean that. Try printing e.message and you should see 'msg'.
I believe what it does mean is the the special meaning of
exception.message (I have forgotten what it is) is gone in Python 3.
In Py3
class MyError(Exception):
def __init__(self, message):
Exception.__init__(self)
self.message = message
e = MyError('msg')
print(e.message)
# 'msg'
No warning any more.
Beyond odd. A bug?
No. A warning about a 'future' change in behavior.
tjr
--
http://mail.python.org/mailman/listinfo/python-list