diff options
author | Guido van Rossum <guido@python.org> | 2007-05-18 00:51:22 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-18 00:51:22 (GMT) |
commit | 68937b4cbcc3e88d4207e6391a311f9b7d067b71 (patch) | |
tree | b5fffb2ee6c7f523ced6f49f9ab35bc22413cbcf /Lib | |
parent | 7ac9d4020100b99b17eeddf65bafa8e87f9f293a (diff) | |
download | cpython-68937b4cbcc3e88d4207e6391a311f9b7d067b71.zip cpython-68937b4cbcc3e88d4207e6391a311f9b7d067b71.tar.gz cpython-68937b4cbcc3e88d4207e6391a311f9b7d067b71.tar.bz2 |
Change some uses of cStringIO.StringIO to io.StringIO.
This is undoubtedly insufficient and in some cases just as broken as before.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/SimpleHTTPServer.py | 5 | ||||
-rw-r--r-- | Lib/SocketServer.py | 5 | ||||
-rwxr-xr-x | Lib/cgi.py | 5 | ||||
-rw-r--r-- | Lib/csv.py | 5 | ||||
-rw-r--r-- | Lib/gettext.py | 5 | ||||
-rw-r--r-- | Lib/httplib.py | 5 | ||||
-rw-r--r-- | Lib/mhlib.py | 5 | ||||
-rwxr-xr-x | Lib/quopri.py | 4 | ||||
-rw-r--r-- | Lib/shelve.py | 13 | ||||
-rw-r--r-- | Lib/shlex.py | 5 | ||||
-rwxr-xr-x | Lib/smtpd.py | 2 | ||||
-rw-r--r-- | Lib/tarfile.py | 5 | ||||
-rw-r--r-- | Lib/tempfile.py | 5 | ||||
-rw-r--r-- | Lib/urllib.py | 20 | ||||
-rw-r--r-- | Lib/urllib2.py | 5 | ||||
-rw-r--r-- | Lib/urlparse.py | 5 | ||||
-rw-r--r-- | Lib/xdrlib.py | 5 | ||||
-rw-r--r-- | Lib/xmlrpclib.py | 7 | ||||
-rw-r--r-- | Lib/zipfile.py | 4 |
19 files changed, 26 insertions, 89 deletions
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py index 86c669e..a1f25be 100644 --- a/Lib/SimpleHTTPServer.py +++ b/Lib/SimpleHTTPServer.py @@ -18,10 +18,7 @@ import urlparse import cgi import shutil import mimetypes -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO +from io import StringIO class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py index 84bbcf6..8e92b80 100644 --- a/Lib/SocketServer.py +++ b/Lib/SocketServer.py @@ -577,10 +577,7 @@ class DatagramRequestHandler(BaseRequestHandler): """Define self.rfile and self.wfile for datagram sockets.""" def setup(self): - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO self.packet, self.socket = self.request self.rfile = StringIO(self.packet) self.wfile = StringIO() @@ -41,10 +41,7 @@ import urllib import mimetools import rfc822 import UserDict -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO +from io import StringIO __all__ = ["MiniFieldStorage", "FieldStorage", "FormContentDict", "SvFormContentDict", "InterpFormContentDict", "FormContent", @@ -11,10 +11,7 @@ from _csv import Error, __version__, writer, reader, register_dialect, \ __doc__ from _csv import Dialect as _Dialect -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO +from io import StringIO __all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE", "Error", "Dialect", "excel", "excel_tab", "reader", "writer", diff --git a/Lib/gettext.py b/Lib/gettext.py index 311e923..a23c2ac 100644 --- a/Lib/gettext.py +++ b/Lib/gettext.py @@ -77,10 +77,7 @@ def c2py(plural): Python lambda function that implements an equivalent expression. """ # Security check, allow only the "n" identifier - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO import token, tokenize tokens = tokenize.generate_tokens(StringIO(plural).readline) try: diff --git a/Lib/httplib.py b/Lib/httplib.py index 84401ac..4c23983 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -71,10 +71,7 @@ import mimetools import socket from urlparse import urlsplit -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO +from io import StringIO __all__ = ["HTTP", "HTTPResponse", "HTTPConnection", "HTTPSConnection", "HTTPException", "NotConnected", "UnknownProtocol", diff --git a/Lib/mhlib.py b/Lib/mhlib.py index cbe8cb1..eecb447 100644 --- a/Lib/mhlib.py +++ b/Lib/mhlib.py @@ -697,10 +697,7 @@ class Message(mimetools.Message): encoding = self.getencoding() if not decode or encoding in ('', '7bit', '8bit', 'binary'): return self.fp.read() - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO output = StringIO() mimetools.decode(self.fp, output, encoding) return output.getvalue() diff --git a/Lib/quopri.py b/Lib/quopri.py index fccfe85..5002cc8 100755 --- a/Lib/quopri.py +++ b/Lib/quopri.py @@ -105,7 +105,7 @@ def encode(input, output, quotetabs, header = 0): def encodestring(s, quotetabs = 0, header = 0): if b2a_qp is not None: return b2a_qp(s, quotetabs = quotetabs, header = header) - from cStringIO import StringIO + from io import StringIO infp = StringIO(s) outfp = StringIO() encode(infp, outfp, quotetabs, header) @@ -159,7 +159,7 @@ def decode(input, output, header = 0): def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) - from cStringIO import StringIO + from io import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) diff --git a/Lib/shelve.py b/Lib/shelve.py index 697ae4f..5aa8263 100644 --- a/Lib/shelve.py +++ b/Lib/shelve.py @@ -56,17 +56,8 @@ entries in the cache, and empty the cache (d.sync() also synchronizes the persistent dictionary on disk, if feasible). """ -# Try using cPickle and cStringIO if available. - -try: - from cPickle import Pickler, Unpickler -except ImportError: - from pickle import Pickler, Unpickler - -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO +from pickle import Pickler, Unpickler +from io import StringIO import UserDict import warnings diff --git a/Lib/shlex.py b/Lib/shlex.py index 520b637..964046d 100644 --- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -11,10 +11,7 @@ import os.path import sys from collections import deque -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO +from io import StringIO __all__ = ["shlex", "split"] diff --git a/Lib/smtpd.py b/Lib/smtpd.py index 73e7777..2e09c5a 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -374,7 +374,7 @@ class PureProxy(SMTPServer): class MailmanProxy(PureProxy): def process_message(self, peer, mailfrom, rcpttos, data): - from cStringIO import StringIO + from io import StringIO from Mailman import Utils from Mailman import Message from Mailman import MailList diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 36bdfa6..ad1473f 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2459,10 +2459,7 @@ class TarFileCompat: def write(self, filename, arcname=None, compress_type=None): self.tarfile.add(filename, arcname) def writestr(self, zinfo, bytes): - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO import calendar zinfo.name = zinfo.filename zinfo.size = zinfo.file_size diff --git a/Lib/tempfile.py b/Lib/tempfile.py index bcd9189..0dd32f3 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -37,10 +37,7 @@ if _os.name == 'mac': import Carbon.Folder as _Folder import Carbon.Folders as _Folders -try: - from cStringIO import StringIO as _StringIO -except: - from StringIO import StringIO as _StringIO +from io import StringIO as _StringIO try: import fcntl as _fcntl diff --git a/Lib/urllib.py b/Lib/urllib.py index cc5ee07..cffa026 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -462,10 +462,7 @@ class URLopener: def open_local_file(self, url): """Use local file.""" import mimetypes, mimetools, email.utils - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO host, file = splithost(url) localname = url2pathname(file) try: @@ -499,10 +496,7 @@ class URLopener: if not isinstance(url, str): raise IOError, ('ftp error', 'proxy support for ftp protocol currently not implemented') import mimetypes, mimetools - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) @@ -568,10 +562,7 @@ class URLopener: # data := *urlchar # parameter := attribute "=" value import mimetools - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO try: [type, data] = url.split(',', 1) except ValueError: @@ -821,10 +812,7 @@ def noheaders(): global _noheaders if _noheaders is None: import mimetools - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO _noheaders = mimetools.Message(StringIO(), 0) _noheaders.fp.close() # Recycle file descriptor return _noheaders diff --git a/Lib/urllib2.py b/Lib/urllib2.py index a0be039..284c921 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -101,10 +101,7 @@ import time import urlparse import bisect -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO +from io import StringIO from urllib import (unwrap, unquote, splittype, splithost, quote, addinfourl, splitport, splitgophertype, splitquery, diff --git a/Lib/urlparse.py b/Lib/urlparse.py index 8cc7a97..e5de53a 100644 --- a/Lib/urlparse.py +++ b/Lib/urlparse.py @@ -350,10 +350,7 @@ def test(): else: fp = open(fn) else: - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO + from io import StringIO fp = StringIO(test_input) while 1: line = fp.readline() diff --git a/Lib/xdrlib.py b/Lib/xdrlib.py index 2f5db9b..055ee82 100644 --- a/Lib/xdrlib.py +++ b/Lib/xdrlib.py @@ -5,10 +5,7 @@ See: RFC 1014 """ import struct -try: - from cStringIO import StringIO as _StringIO -except ImportError: - from StringIO import StringIO as _StringIO +from io import StringIO as _StringIO __all__ = ["Error", "Packer", "Unpacker", "ConversionError"] diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py index 3347e54..9684ab0 100644 --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -370,10 +370,7 @@ def _datetime_type(data): # @param data An 8-bit string containing arbitrary data. import base64 -try: - import cStringIO as StringIO -except ImportError: - import StringIO +import io class Binary: """Wrapper for binary data.""" @@ -404,7 +401,7 @@ class Binary: def encode(self, out): out.write("<value><base64>\n") - base64.encode(StringIO.StringIO(self.data), out) + base64.encode(io.StringIO(self.data), out) out.write("</base64></value>\n") def _binary(data): diff --git a/Lib/zipfile.py b/Lib/zipfile.py index fa7e910..1e180fc 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -2,7 +2,7 @@ Read and write ZIP files. """ import struct, os, time, sys -import binascii, cStringIO +import binascii, io try: import zlib # We may need its compression method @@ -661,7 +661,7 @@ class ZipFile: self.start_dir = offset_cd + concat fp.seek(self.start_dir, 0) data = fp.read(size_cd) - fp = cStringIO.StringIO(data) + fp = io.StringIO(data) total = 0 while total < size_cd: centdir = fp.read(46) |