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 vstinner
Recipients vstinner
Date 2015-03-24.14:48:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427208524.49.0.466002808612.issue23763@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-03-24 14:48:44vstinnersetrecipients: + vstinner
2015-03-24 14:48:44vstinnersetmessageid: <1427208524.49.0.466002808612.issue23763@psf.upfronthosting.co.za>
2015-03-24 14:48:44vstinnerlinkissue23763 messages
2015-03-24 14:48:44vstinnercreate