bpo-38530: Require 50% similarity in NameError and AttributeError suggestions (GH-25584)

This commit is contained in:
Dennis Sweeney 2021-04-26 20:22:27 -04:00 committed by GitHub
parent 7244c0060d
commit 284c52da09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 116 additions and 1 deletions

View file

@ -102,7 +102,10 @@ calculate_suggestions(PyObject *dir,
if (current_distance == -1) {
return NULL;
}
if (current_distance == 0 || current_distance > MAX_DISTANCE) {
if (current_distance == 0 ||
current_distance > MAX_DISTANCE ||
current_distance * 2 > name_size)
{
continue;
}
if (!suggestion || current_distance < suggestion_distance) {