]> granicus.if.org Git - python/commitdiff
SF patch# 1764815 by Paul Colomiets.
authorGuido van Rossum <guido@python.org>
Fri, 3 Aug 2007 19:03:39 +0000 (19:03 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 3 Aug 2007 19:03:39 +0000 (19:03 +0000)
Fix for test_socketserver.
Use io.BytesIO instead of io.StringIO, and adjust tests.

Lib/SocketServer.py
Lib/test/test_socketserver.py

index c6e71ebbfdcbc579cfd6aeb1829a992e41b3c6c9..994a3c6e8c7833069402d5c68c027dbf763e2d04 100644 (file)
@@ -574,10 +574,10 @@ class DatagramRequestHandler(BaseRequestHandler):
     """Define self.rfile and self.wfile for datagram sockets."""
 
     def setup(self):
-        from io import StringIO
+        from io import BytesIO
         self.packet, self.socket = self.request
-        self.rfile = StringIO(self.packet)
-        self.wfile = StringIO()
+        self.rfile = BytesIO(self.packet)
+        self.wfile = BytesIO()
 
     def finish(self):
         self.socket.sendto(self.wfile.getvalue(), self.client_address)
index da936a4780dd48979a45bf6997c4108c51ee82c3..6682d7165bda70a35062b616a366ceef19382b5b 100644 (file)
@@ -38,7 +38,7 @@ class MyMixinServer:
         self.server_close()
         raise
 
-teststring = "hello world\n"
+teststring = b"hello world\n"
 
 def receive(sock, n, timeout=20):
     r, w, x = select.select([sock], [], [], timeout)
@@ -51,7 +51,7 @@ def testdgram(proto, addr):
     s = socket.socket(proto, socket.SOCK_DGRAM)
     s.sendto(teststring, addr)
     buf = data = receive(s, 100)
-    while data and '\n' not in buf:
+    while data and b'\n' not in buf:
         data = receive(s, 100)
         buf += data
     verify(buf == teststring)
@@ -62,7 +62,7 @@ def teststream(proto, addr):
     s.connect(addr)
     s.sendall(teststring)
     buf = data = receive(s, 100)
-    while data and '\n' not in buf:
+    while data and b'\n' not in buf:
         data = receive(s, 100)
         buf += data
     verify(buf == teststring)