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 serhiy.storchaka
Recipients serhiy.storchaka, vstinner, yselivanov
Date 2016-10-10.19:50:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1476129027.52.0.516927582831.issue28410@psf.upfronthosting.co.za>
In-reply-to
Content
Sometimes after catching an exception we need to raise new exception of specific type, but save the information about current exception. In Python the syntax "raise ... from ..." serves this purpose (PEP 3134). But in C the code that implements this is too cumbersome. Proposed patch adds private convenient function that raises an exception and sets previously raised exception as its __context__ and __cause__ attributes. This is a generalized version of gen_chain_runtime_error() from Objects/genobject.c. It could be reused in three other places: Objects/abstract.c, Objects/unicodeobject.c, and Modules/zipimport.c (currently only __context__ is set, but setting __cause__ looks preferable), and in new code for issue28214. Maybe there are other opportunities.
History
Date User Action Args
2016-10-10 19:50:27serhiy.storchakasetrecipients: + serhiy.storchaka, vstinner, yselivanov
2016-10-10 19:50:27serhiy.storchakasetmessageid: <1476129027.52.0.516927582831.issue28410@psf.upfronthosting.co.za>
2016-10-10 19:50:27serhiy.storchakalinkissue28410 messages
2016-10-10 19:50:27serhiy.storchakacreate