Author: walter.doerwald
Date: Tue Jun  5 15:41:53 2007
New Revision: 55760

Modified:
   python/branches/py3k-struni/Lib/test/test_socket.py
   python/branches/py3k-struni/Modules/socketmodule.c
Log:
Simplify socket_repr() by using PyUnicode_FromFormat()
directly. Add a test that calls socket_repr().


Modified: python/branches/py3k-struni/Lib/test/test_socket.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_socket.py (original)
+++ python/branches/py3k-struni/Lib/test/test_socket.py Tue Jun  5 15:41:53 2007
@@ -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)

Modified: python/branches/py3k-struni/Modules/socketmodule.c
==============================================================================
--- python/branches/py3k-struni/Modules/socketmodule.c  (original)
+++ python/branches/py3k-struni/Modules/socketmodule.c  Tue Jun  5 15:41:53 2007
@@ -2787,13 +2787,11 @@
                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);
 }
 
 
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to