bpo-44655: Don't include suggestions for attributes that are the same as the missing one (GH-27197) (GH-27198)

(cherry picked from commit 6714dec5e1)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-07-16 14:16:08 -07:00 committed by GitHub
parent 42a5514cca
commit a0b1d401db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

@ -149,6 +149,9 @@ calculate_suggestions(PyObject *dir,
if (item_str == NULL) {
return NULL;
}
if (PyUnicode_CompareWithASCIIString(name, item_str) == 0) {
continue;
}
// No more than 1/3 of the involved characters should need changed.
Py_ssize_t max_distance = (name_size + item_size + 3) * MOVE_COST / 6;
// Don't take matches we've already beaten.