Use cStringIO where available.

This commit is contained in:
Raymond Hettinger 2004-12-31 19:15:26 +00:00
parent 54266fce8d
commit a617271dbd
8 changed files with 55 additions and 19 deletions

View file

@ -575,10 +575,13 @@ class DatagramRequestHandler(BaseRequestHandler):
"""Define self.rfile and self.wfile for datagram sockets."""
def setup(self):
import StringIO
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
self.packet, self.socket = self.request
self.rfile = StringIO.StringIO(self.packet)
self.wfile = StringIO.StringIO()
self.rfile = StringIO(self.packet)
self.wfile = StringIO()
def finish(self):
self.socket.sendto(self.wfile.getvalue(), self.client_address)