diff -r 50d93fe73726 Lib/test/test_socket.py --- a/Lib/test/test_socket.py Tue May 27 03:31:32 2014 -0400 +++ b/Lib/test/test_socket.py Tue May 27 20:00:58 2014 +0700 @@ -19,6 +19,7 @@ import math import pickle import struct +import pydoc try: import multiprocessing except ImportError: @@ -4974,6 +4975,17 @@ socket.setdefaulttimeout(t) +class TestSocketPyDoc(unittest.TestCase): + + # issue 20689 + def test_pydoc_display_AddressFamily(self): + with support.captured_stdout() as help_io: + pydoc.help(socket) + helptext = help_io.getvalue() + # Should we test all classes and exceptions? + self.assertIn('class AddressFamily', helptext) + + @unittest.skipUnless(os.name == "nt", "Windows specific") @unittest.skipUnless(multiprocessing, "need multiprocessing") class TestSocketSharing(SocketTCPTest): @@ -5128,6 +5140,7 @@ # These are slow when setitimer() is not available InterruptedRecvTimeoutTest, InterruptedSendTimeoutTest, + TestSocketPyDoc, TestSocketSharing, ]) diff -r 50d93fe73726 Modules/socketmodule.c --- a/Modules/socketmodule.c Tue May 27 03:31:32 2014 -0400 +++ b/Modules/socketmodule.c Tue May 27 20:00:58 2014 +0700 @@ -5817,6 +5817,10 @@ if (PyModule_AddObject(m, "socket", (PyObject *)&sock_type) != 0) return NULL; + Py_INCREF((PyObject *)&sock_type); + if (PyModule_AddObject(m, "AddressFamily", + (PyObject *)&sock_type) != 0) + return NULL; #ifdef ENABLE_IPV6 has_ipv6 = Py_True;