Message239133
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. |
|
Date |
User |
Action |
Args |
2015-03-24 14:48:44 | vstinner | set | recipients:
+ vstinner |
2015-03-24 14:48:44 | vstinner | set | messageid: <1427208524.49.0.466002808612.issue23763@psf.upfronthosting.co.za> |
2015-03-24 14:48:44 | vstinner | link | issue23763 messages |
2015-03-24 14:48:44 | vstinner | create | |
|