[issue23763] Chain exceptions in C

STINNER Victor report at bugs.python.org
Tue Mar 24 15:46:38 CET 2015


STINNER Victor added the comment:

> For the next step, I propose to explicitly clear the current exception before raising a new exception.

Attached pyerr_match_clear.patch implements this. It's only a work-in-progress. I prefer to get feedback on the patch before finishing it.

The patch checks also which exception was raised using PyErr_ExceptionMatches() to avoid hiding import exceptions.

Since my patch makes assumption on which exception is expected, it can change the behaviour of functions if I forgot a different exception which is also supposed to be replaced. Example: only catch ValueError and replace it with ValueError, whereas OverflowError must also be replaced with ValueError.

----------
Added file: http://bugs.python.org/file38667/pyerr_match_clear.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23763>
_______________________________________


More information about the Python-bugs-list mailing list