self.assertNotIn("blech", err.getvalue())
+ def test_unbound_local_error_doesn_not_match(self):
+ def foo():
+ something = 3
+ print(somethong)
+ somethong = 3
+
+ try:
+ foo()
+ except UnboundLocalError as exc:
+ with support.captured_stderr() as err:
+ sys.__excepthook__(*sys.exc_info())
+
+ self.assertNotIn("something", err.getvalue())
+
+
class AttributeErrorTests(unittest.TestCase):
def test_attributes(self):
# Setting 'attr' should not be a problem.
PyObject *_Py_Offer_Suggestions(PyObject *exception) {
PyObject *result = NULL;
assert(!PyErr_Occurred());
- if (PyErr_GivenExceptionMatches(exception, PyExc_AttributeError)) {
+ if (Py_IS_TYPE(exception, (PyTypeObject*)PyExc_AttributeError)) {
result = offer_suggestions_for_attribute_error((PyAttributeErrorObject *) exception);
- } else if (PyErr_GivenExceptionMatches(exception, PyExc_NameError)) {
+ } else if (Py_IS_TYPE(exception, (PyTypeObject*)PyExc_NameError)) {
result = offer_suggestions_for_name_error((PyNameErrorObject *) exception);
}
return result;