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

This commit is contained in:
Pablo Galindo Salgado 2021-07-16 21:58:21 +01:00 committed by GitHub
parent c90c591e51
commit 6714dec5e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

@ -1916,6 +1916,18 @@ def __getattr__(self, attr):
self.assertIn("blech", err.getvalue())
def test_getattr_suggestions_for_same_name(self):
class A:
def __dir__(self):
return ['blech']
try:
A().blech
except AttributeError as exc:
with support.captured_stderr() as err:
sys.__excepthook__(*sys.exc_info())
self.assertNotIn("Did you mean", err.getvalue())
def test_attribute_error_with_failing_dict(self):
class T:
bluch = 1