directly. Add a test that calls socket_repr().
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)
return NULL;
}
#endif
- PyOS_snprintf(
- buf, sizeof(buf),
+ return PyUnicode_FromFormat(
"<socket object, fd=%ld, family=%d, type=%d, proto=%d>",
(long)s->sock_fd, s->sock_family,
s->sock_type,
s->sock_proto);
- return PyUnicode_FromString(buf);
}