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 steven.daprano
Recipients cool-RR, steven.daprano
Date 2021-01-22.22:29:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
It is intended behaviour. `raise ... from` is a general mechanism that you can call anywhere, it is not just limited to raising from the previous exception. It is designed for explicitly setting the chained exception to some arbitrary exception. See the PEP:

>>> raise ValueError('bad value') from IndexError('bad index')
IndexError: bad index

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

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: bad value

If you wish to chain from the current exception, you have to chain from the current exception, and not create a new one.

This is not an interpreter bug, it's working fine. Your first instinct was correct: your colleague had written "bad code" and his intention was probably to raise from the exception he had just caught. 

Or just don't do anything. A `raise exception` inside an except block will be automatically chained with the current exception unless you explicitly disable it with `raise exception from None`.
Date User Action Args
2021-01-22 22:29:37steven.dapranosetrecipients: + steven.daprano, cool-RR
2021-01-22 22:29:37steven.dapranosetmessageid: <>
2021-01-22 22:29:37steven.dapranolinkissue43002 messages
2021-01-22 22:29:37steven.dapranocreate