mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
bpo-25460: Surround suggestions by quotes (GH-25473)
This commit is contained in:
parent
4f9ffa8f9c
commit
7a04116246
2 changed files with 16 additions and 16 deletions
|
@ -1453,12 +1453,12 @@ class NameErrorTests(unittest.TestCase):
|
||||||
bluc = None
|
bluc = None
|
||||||
print(bluch)
|
print(bluch)
|
||||||
|
|
||||||
for func, suggestion in [(Substitution, "blech?"),
|
for func, suggestion in [(Substitution, "'blech'?"),
|
||||||
(Elimination, "blch?"),
|
(Elimination, "'blch'?"),
|
||||||
(Addition, "bluchin?"),
|
(Addition, "'bluchin'?"),
|
||||||
(EliminationOverAddition, "blucha?"),
|
(EliminationOverAddition, "'blucha'?"),
|
||||||
(SubstitutionOverElimination, "blach?"),
|
(SubstitutionOverElimination, "'blach'?"),
|
||||||
(SubstitutionOverAddition, "blach?")]:
|
(SubstitutionOverAddition, "'blach'?")]:
|
||||||
err = None
|
err = None
|
||||||
try:
|
try:
|
||||||
func()
|
func()
|
||||||
|
@ -1475,7 +1475,7 @@ class NameErrorTests(unittest.TestCase):
|
||||||
except NameError as exc:
|
except NameError as exc:
|
||||||
with support.captured_stderr() as err:
|
with support.captured_stderr() as err:
|
||||||
sys.__excepthook__(*sys.exc_info())
|
sys.__excepthook__(*sys.exc_info())
|
||||||
self.assertIn("global_for_suggestions?", err.getvalue())
|
self.assertIn("'global_for_suggestions'?", err.getvalue())
|
||||||
|
|
||||||
def test_name_error_suggestions_from_builtins(self):
|
def test_name_error_suggestions_from_builtins(self):
|
||||||
def func():
|
def func():
|
||||||
|
@ -1485,7 +1485,7 @@ class NameErrorTests(unittest.TestCase):
|
||||||
except NameError as exc:
|
except NameError as exc:
|
||||||
with support.captured_stderr() as err:
|
with support.captured_stderr() as err:
|
||||||
sys.__excepthook__(*sys.exc_info())
|
sys.__excepthook__(*sys.exc_info())
|
||||||
self.assertIn("AttributeError?", err.getvalue())
|
self.assertIn("'AttributeError'?", err.getvalue())
|
||||||
|
|
||||||
def test_name_error_suggestions_do_not_trigger_for_long_names(self):
|
def test_name_error_suggestions_do_not_trigger_for_long_names(self):
|
||||||
def f():
|
def f():
|
||||||
|
@ -1628,12 +1628,12 @@ class AttributeErrorTests(unittest.TestCase):
|
||||||
blucha = None
|
blucha = None
|
||||||
bluc = None
|
bluc = None
|
||||||
|
|
||||||
for cls, suggestion in [(Substitution, "blech?"),
|
for cls, suggestion in [(Substitution, "'blech'?"),
|
||||||
(Elimination, "blch?"),
|
(Elimination, "'blch'?"),
|
||||||
(Addition, "bluchin?"),
|
(Addition, "'bluchin'?"),
|
||||||
(EliminationOverAddition, "bluc?"),
|
(EliminationOverAddition, "'bluc'?"),
|
||||||
(SubstitutionOverElimination, "blach?"),
|
(SubstitutionOverElimination, "'blach'?"),
|
||||||
(SubstitutionOverAddition, "blach?")]:
|
(SubstitutionOverAddition, "'blach'?")]:
|
||||||
try:
|
try:
|
||||||
cls().bluch
|
cls().bluch
|
||||||
except AttributeError as exc:
|
except AttributeError as exc:
|
||||||
|
|
|
@ -956,10 +956,10 @@ print_exception(PyObject *f, PyObject *value)
|
||||||
PyObject* suggestions = _Py_Offer_Suggestions(value);
|
PyObject* suggestions = _Py_Offer_Suggestions(value);
|
||||||
if (suggestions) {
|
if (suggestions) {
|
||||||
// Add a trailer ". Did you mean: (...)?"
|
// Add a trailer ". Did you mean: (...)?"
|
||||||
err = PyFile_WriteString(". Did you mean: ", f);
|
err = PyFile_WriteString(". Did you mean: '", f);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
err = PyFile_WriteObject(suggestions, f, Py_PRINT_RAW);
|
err = PyFile_WriteObject(suggestions, f, Py_PRINT_RAW);
|
||||||
err += PyFile_WriteString("?", f);
|
err += PyFile_WriteString("'?", f);
|
||||||
}
|
}
|
||||||
Py_DECREF(suggestions);
|
Py_DECREF(suggestions);
|
||||||
} else if (PyErr_Occurred()) {
|
} else if (PyErr_Occurred()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue