mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-98254: Include stdlib module names in error messages for NameErrors (#98255)
This commit is contained in:
parent
3a639bbeac
commit
bb56dead33
6 changed files with 101 additions and 31 deletions
|
@ -1107,16 +1107,9 @@ print_exception_suggestions(struct exception_print_context *ctx,
|
|||
PyObject *f = ctx->file;
|
||||
PyObject *suggestions = _Py_Offer_Suggestions(value);
|
||||
if (suggestions) {
|
||||
// Add a trailer ". Did you mean: (...)?"
|
||||
if (PyFile_WriteString(". Did you mean: '", f) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (PyFile_WriteObject(suggestions, f, Py_PRINT_RAW) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (PyFile_WriteString("'?", f) < 0) {
|
||||
goto error;
|
||||
}
|
||||
Py_DECREF(suggestions);
|
||||
}
|
||||
else if (PyErr_Occurred()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue