File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1537,6 +1537,21 @@ def f():
1537
1537
1538
1538
self .assertNotIn ("blech" , err .getvalue ())
1539
1539
1540
+ def test_unbound_local_error_doesn_not_match (self ):
1541
+ def foo ():
1542
+ something = 3
1543
+ print (somethong )
1544
+ somethong = 3
1545
+
1546
+ try :
1547
+ foo ()
1548
+ except UnboundLocalError as exc :
1549
+ with support .captured_stderr () as err :
1550
+ sys .__excepthook__ (* sys .exc_info ())
1551
+
1552
+ self .assertNotIn ("something" , err .getvalue ())
1553
+
1554
+
1540
1555
class AttributeErrorTests (unittest .TestCase ):
1541
1556
def test_attributes (self ):
1542
1557
# Setting 'attr' should not be a problem.
Original file line number Diff line number Diff line change @@ -181,9 +181,9 @@ offer_suggestions_for_name_error(PyNameErrorObject *exc) {
181
181
PyObject * _Py_Offer_Suggestions (PyObject * exception ) {
182
182
PyObject * result = NULL ;
183
183
assert (!PyErr_Occurred ());
184
- if (PyErr_GivenExceptionMatches (exception , PyExc_AttributeError )) {
184
+ if (Py_IS_TYPE (exception , ( PyTypeObject * ) PyExc_AttributeError )) {
185
185
result = offer_suggestions_for_attribute_error ((PyAttributeErrorObject * ) exception );
186
- } else if (PyErr_GivenExceptionMatches (exception , PyExc_NameError )) {
186
+ } else if (Py_IS_TYPE (exception , ( PyTypeObject * ) PyExc_NameError )) {
187
187
result = offer_suggestions_for_name_error ((PyNameErrorObject * ) exception );
188
188
}
189
189
return result ;
You can’t perform that action at this time.
0 commit comments