bpo-38530: Make sure that failing to generate suggestions on failure will not propagate exceptions (GH-25408)
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 4f3c9ab..ebeb67b 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -1695,6 +1695,20 @@ def __getattr__(self, attr):
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):