mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +00:00
bpo-38530: Match exactly AttributeError and NameError when offering suggestions (GH-25443)
This commit is contained in:
parent
3b82cae774
commit
0ad81d4db2
2 changed files with 17 additions and 2 deletions
|
@ -181,9 +181,9 @@ offer_suggestions_for_name_error(PyNameErrorObject *exc) {
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue