bpo-38530: Cover more error paths in error suggestion functions (GH-25462)

diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index b730858..d1e1b19 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -1741,6 +1741,16 @@ def __dir__(self):
         self.assertNotIn("blech", err.getvalue())
         self.assertNotIn("oh no!", err.getvalue())
 
+    def test_attribute_error_with_bad_name(self):
+        try:
+            raise AttributeError(name=12, obj=23)
+        except AttributeError as exc:
+            with support.captured_stderr() as err:
+                sys.__excepthook__(*sys.exc_info())
+
+        self.assertNotIn("?", err.getvalue())
+
+
 class ImportErrorTests(unittest.TestCase):
 
     def test_attributes(self):