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 brett.cannon
Recipients aisaac, brett.cannon, dgrisby, exarkun, georg.brandl, ivank
Date 2009-09-07.22:07:53
SpamBayes Score 1.0855892e-09
Marked as misclassified No
Message-id <bbaeab100909071507m670756d7oa233cd7d3aed1f81@mail.gmail.com>
In-reply-to <1252360675.56.0.45055871137.issue6844@psf.upfronthosting.co.za>
Content
On Mon, Sep 7, 2009 at 14:57, Jean-Paul Calderone<report@bugs.python.org> wrote:
>
> Jean-Paul Calderone <exarkun@divmod.com> added the comment:
>
> 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?

Works for me. If someone can create a patch for that I will review it
and apply it to 2.6 (the warning will be removed from 2.7 and so will
the attribute).
History
Date User Action Args
2009-09-07 22:07:55brett.cannonsetrecipients: + brett.cannon, georg.brandl, dgrisby, exarkun, ivank, aisaac
2009-09-07 22:07:54brett.cannonlinkissue6844 messages
2009-09-07 22:07:54brett.cannoncreate