STINNER Victor added the comment:
pyerr_match_assertion.patch: Modify PyErr_ExceptionMatches() to raise an
exception if it is called with no exception set.
This patch can be used to ensure that pyerr_match_clear.patch doesn't introduce
regression.
Example:
- PyErr_Format(PyExc_TypeError,
- "expected %s instance instead of %s",
- ((PyTypeObject *)type)->tp_name,
- Py_TYPE(value)->tp_name);
+
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_Clear();
+ PyErr_Format(PyExc_TypeError,
+ "expected %s instance instead of %s",
+ ((PyTypeObject *)type)->tp_name,
+ Py_TYPE(value)->tp_name);
+ }
This change is wrong is not exception is set, because PyErr_ExceptionMatches()
returns 0 if no exception was raised.
----------
Added file: http://bugs.python.org/file38668/pyerr_match_assertion.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23763>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com