bpo-38530: Make sure that failing to generate suggestions on failure will not propagate exceptions (GH-25408)

This commit is contained in:
Pablo Galindo 2021-04-14 18:58:28 +01:00 committed by GitHub
parent 0c4c436325
commit e07f4ab26a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 7 deletions

View file

@ -1695,6 +1695,20 @@ class AttributeErrorTests(unittest.TestCase):
self.assertIn("blech", err.getvalue())
def test_attribute_error_with_failing_dict(self):
class T:
bluch = 1
def __dir__(self):
raise AttributeError("oh no!")
try:
T().blich
except AttributeError as exc:
with support.captured_stderr() as err:
sys.__excepthook__(*sys.exc_info())
self.assertNotIn("blech", err.getvalue())
self.assertNotIn("oh no!", err.getvalue())
class ImportErrorTests(unittest.TestCase):