Simplify socket_repr() by using PyUnicode_FromFormat()
directly. Add a test that calls socket_repr().
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index cfb293f..8ba2ceb 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -217,6 +217,10 @@
class GeneralModuleTests(unittest.TestCase):
+ def test_repr(self):
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.assert_(repr(s).startswith("<socket.socket object"))
+
def test_weakref(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
p = proxy(s)