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 exarkun
Recipients aisaac, brett.cannon, dgrisby, exarkun, georg.brandl, ivank
Date 2009-09-07.21:57:53
SpamBayes Score 1.0276264e-07
Marked as misclassified No
Message-id <1252360675.56.0.45055871137.issue6844@psf.upfronthosting.co.za>
In-reply-to
Content
Alright.  So in Python 3.1, this is the behavior:

>>> BaseException().message
(attribute error)
>>> BaseException("foo").message
(attribute error)
>>> BaseException("foo", "bar").message
(attribute error)
>>> x = BaseException()
>>> x.message = "foo"
>>> x.message
'foo'
>>> x = BaseException("foo")
>>> x.message = "bar"
>>> x.message
'bar'
>>> x = BaseException("foo")
>>> x.message = "bar"
>>> x.message
'bar'

So I propose the following as the new behavior for 2.x:

>>> BaseException().message
(deprecation warning)
''
>>> BaseException("foo").message
(deprecation warning)
'foo'
>>> BaseException("foo", "bar").message
(deprecation warning)
''
>>> x = BaseException()
>>> x.message = "foo"
>>> x.message
'foo'
>>> x = BaseException("foo")
>>> x.message = "bar"
>>> x.message
'bar'
>>> x = BaseException("foo", "bar")
>>> x.message = "baz"
>>> x.message
'baz'

Summarized: emit a warning when the same code in Python 3.1 would raise
an exception; let all other cases pass.

There is one other case that I would think about changing, but I don't
see how it can, given the behavior that is implemented in 3.1 already. 
BaseException("a message") is a Python 2.5-supported way of creating an
exception with a value for its message attribute.  This no longer works
in Python 3.1.  So, arguably, this is another case where a deprecation
warning should be emitted.  However, this would be pretty obnoxious,
since BaseException("a message") in Python 2.4 (by way of Exception("a
message"), of course, since Python 2.4 did not have BaseException) was
perfectly valid.  It seems like BaseException(string) should have been
deprecated and BaseException(tuple) been made the preferred API.  That's
for another time, though.

How does the above proposed deprecation behavior sound?
History
Date User Action Args
2009-09-07 21:57:55exarkunsetrecipients: + exarkun, brett.cannon, georg.brandl, dgrisby, ivank, aisaac
2009-09-07 21:57:55exarkunsetmessageid: <1252360675.56.0.45055871137.issue6844@psf.upfronthosting.co.za>
2009-09-07 21:57:54exarkunlinkissue6844 messages
2009-09-07 21:57:53exarkuncreate