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():
15371537
15381538 self .assertNotIn ("blech" , err .getvalue ())
15391539
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+
15401555class AttributeErrorTests (unittest .TestCase ):
15411556 def test_attributes (self ):
15421557 # 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) {
181181PyObject * _Py_Offer_Suggestions (PyObject * exception ) {
182182 PyObject * result = NULL ;
183183 assert (!PyErr_Occurred ());
184- if (PyErr_GivenExceptionMatches (exception , PyExc_AttributeError )) {
184+ if (Py_IS_TYPE (exception , ( PyTypeObject * ) PyExc_AttributeError )) {
185185 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 )) {
187187 result = offer_suggestions_for_name_error ((PyNameErrorObject * ) exception );
188188 }
189189 return result ;
You can’t perform that action at this time.
0 commit comments