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 ethan.furman
Recipients Arfrever, Tyler.Crompton, ethan.furman, georg.brandl, ncoghlan, python-dev
Date 2012-12-08.16:59:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1354985956.6.0.815394333998.issue15209@psf.upfronthosting.co.za>
In-reply-to
Content
There is one typo and one error in the first paragraph of the patch:

> When raising a new exception (rather than
> using to bare ``raise`` to re-raise the
         ^ should be an 'a'

> exception currently being handled), the
> implicit exception chain can be made explicit
> by using :keyword:`from` with :keyword:`raise`.
> The single argument to :keyword:`from` must be
> an exception or ``None``. It will be set as
> :attr:`__cause__` on the raised exception.

> Setting :attr:`__cause__` also implicitly sets
> the :attr:`__suppress_context__` attribute to ``True``.

The last sentence is incorrect -- __suppress_context__ is only set to True if __cause__ is set to None; if __cause__ is set to any other exception __suppress_context__ remains False and the new exception chain will be printed:

>>> try:
...   raise ValueError
... except:
...   raise NameError from KeyError
...
KeyError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
NameError

This is easily fixed by adding 'to ``None``':

> Setting :attr:`__cause__` to ``None`` also implicitly sets
> the :attr:`__suppress_context__` attribute to ``True``.
History
Date User Action Args
2012-12-08 16:59:16ethan.furmansetrecipients: + ethan.furman, georg.brandl, ncoghlan, Arfrever, python-dev, Tyler.Crompton
2012-12-08 16:59:16ethan.furmansetmessageid: <1354985956.6.0.815394333998.issue15209@psf.upfronthosting.co.za>
2012-12-08 16:59:16ethan.furmanlinkissue15209 messages
2012-12-08 16:59:16ethan.furmancreate