Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 32084da..6bdb6c9 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -667,6 +667,8 @@
                                type=socket.SOCK_STREAM, proto=0,
                                flags=socket.AI_PASSIVE)
         self.assertEqual(a, b)
+        # Issue #6697.
+        self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800')
 
     def test_getnameinfo(self):
         # only IP addresses are allowed