[Python-3000-checkins] r55423 - python/branches/py3k-struni/Lib/SimpleHTTPServer.py python/branches/py3k-struni/Lib/SocketServer.py python/branches/py3k-struni/Lib/cgi.py python/branches/py3k-struni/Lib/csv.py python/branches/py3k-struni/Lib/gettext.py python/branches/py3k-struni/Lib/httplib.py python/branches/py3k-struni/Lib/mhlib.py python/branches/py3k-struni/Lib/quopri.py python/branches/py3k-struni/Lib/shelve.py python/branches/py3k-struni/Lib/shlex.py python/branches/py3k-struni/Lib/smtpd.py python/branches/py3k-struni/Lib/tarfile.py python/branches/py3k-struni/Lib/tempfile.py python/branches/py3k-struni/Lib/urllib.py python/branches/py3k-struni/Lib/urllib2.py python/branches/py3k-struni/Lib/urlparse.py python/branches/py3k-struni/Lib/xdrlib.py python/branches/py3k-struni/Lib/xmlrpclib.py python/branches/py3k-struni/Lib/zipfile.py

guido.van.rossum python-3000-checkins at python.org
Fri May 18 02:51:26 CEST 2007


Author: guido.van.rossum
Date: Fri May 18 02:51:22 2007
New Revision: 55423

Modified:
   python/branches/py3k-struni/Lib/SimpleHTTPServer.py
   python/branches/py3k-struni/Lib/SocketServer.py
   python/branches/py3k-struni/Lib/cgi.py
   python/branches/py3k-struni/Lib/csv.py
   python/branches/py3k-struni/Lib/gettext.py
   python/branches/py3k-struni/Lib/httplib.py
   python/branches/py3k-struni/Lib/mhlib.py
   python/branches/py3k-struni/Lib/quopri.py
   python/branches/py3k-struni/Lib/shelve.py
   python/branches/py3k-struni/Lib/shlex.py
   python/branches/py3k-struni/Lib/smtpd.py
   python/branches/py3k-struni/Lib/tarfile.py
   python/branches/py3k-struni/Lib/tempfile.py
   python/branches/py3k-struni/Lib/urllib.py
   python/branches/py3k-struni/Lib/urllib2.py
   python/branches/py3k-struni/Lib/urlparse.py
   python/branches/py3k-struni/Lib/xdrlib.py
   python/branches/py3k-struni/Lib/xmlrpclib.py
   python/branches/py3k-struni/Lib/zipfile.py
Log:
Change some uses of cStringIO.StringIO to io.StringIO.
This is undoubtedly insufficient and in some cases just as broken as before.


Modified: python/branches/py3k-struni/Lib/SimpleHTTPServer.py
==============================================================================
--- python/branches/py3k-struni/Lib/SimpleHTTPServer.py	(original)
+++ python/branches/py3k-struni/Lib/SimpleHTTPServer.py	Fri May 18 02:51:22 2007
@@ -18,10 +18,7 @@
 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):

Modified: python/branches/py3k-struni/Lib/SocketServer.py
==============================================================================
--- python/branches/py3k-struni/Lib/SocketServer.py	(original)
+++ python/branches/py3k-struni/Lib/SocketServer.py	Fri May 18 02:51:22 2007
@@ -577,10 +577,7 @@
     """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()

Modified: python/branches/py3k-struni/Lib/cgi.py
==============================================================================
--- python/branches/py3k-struni/Lib/cgi.py	(original)
+++ python/branches/py3k-struni/Lib/cgi.py	Fri May 18 02:51:22 2007
@@ -41,10 +41,7 @@
 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",

Modified: python/branches/py3k-struni/Lib/csv.py
==============================================================================
--- python/branches/py3k-struni/Lib/csv.py	(original)
+++ python/branches/py3k-struni/Lib/csv.py	Fri May 18 02:51:22 2007
@@ -11,10 +11,7 @@
                  __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",

Modified: python/branches/py3k-struni/Lib/gettext.py
==============================================================================
--- python/branches/py3k-struni/Lib/gettext.py	(original)
+++ python/branches/py3k-struni/Lib/gettext.py	Fri May 18 02:51:22 2007
@@ -77,10 +77,7 @@
     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:

Modified: python/branches/py3k-struni/Lib/httplib.py
==============================================================================
--- python/branches/py3k-struni/Lib/httplib.py	(original)
+++ python/branches/py3k-struni/Lib/httplib.py	Fri May 18 02:51:22 2007
@@ -71,10 +71,7 @@
 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",

Modified: python/branches/py3k-struni/Lib/mhlib.py
==============================================================================
--- python/branches/py3k-struni/Lib/mhlib.py	(original)
+++ python/branches/py3k-struni/Lib/mhlib.py	Fri May 18 02:51:22 2007
@@ -697,10 +697,7 @@
         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()

Modified: python/branches/py3k-struni/Lib/quopri.py
==============================================================================
--- python/branches/py3k-struni/Lib/quopri.py	(original)
+++ python/branches/py3k-struni/Lib/quopri.py	Fri May 18 02:51:22 2007
@@ -105,7 +105,7 @@
 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 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)

Modified: python/branches/py3k-struni/Lib/shelve.py
==============================================================================
--- python/branches/py3k-struni/Lib/shelve.py	(original)
+++ python/branches/py3k-struni/Lib/shelve.py	Fri May 18 02:51:22 2007
@@ -56,17 +56,8 @@
 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

Modified: python/branches/py3k-struni/Lib/shlex.py
==============================================================================
--- python/branches/py3k-struni/Lib/shlex.py	(original)
+++ python/branches/py3k-struni/Lib/shlex.py	Fri May 18 02:51:22 2007
@@ -11,10 +11,7 @@
 import sys
 from collections import deque
 
-try:
-    from cStringIO import StringIO
-except ImportError:
-    from StringIO import StringIO
+from io import StringIO
 
 __all__ = ["shlex", "split"]
 

Modified: python/branches/py3k-struni/Lib/smtpd.py
==============================================================================
--- python/branches/py3k-struni/Lib/smtpd.py	(original)
+++ python/branches/py3k-struni/Lib/smtpd.py	Fri May 18 02:51:22 2007
@@ -374,7 +374,7 @@
 
 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

Modified: python/branches/py3k-struni/Lib/tarfile.py
==============================================================================
--- python/branches/py3k-struni/Lib/tarfile.py	(original)
+++ python/branches/py3k-struni/Lib/tarfile.py	Fri May 18 02:51:22 2007
@@ -2459,10 +2459,7 @@
     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

Modified: python/branches/py3k-struni/Lib/tempfile.py
==============================================================================
--- python/branches/py3k-struni/Lib/tempfile.py	(original)
+++ python/branches/py3k-struni/Lib/tempfile.py	Fri May 18 02:51:22 2007
@@ -37,10 +37,7 @@
     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

Modified: python/branches/py3k-struni/Lib/urllib.py
==============================================================================
--- python/branches/py3k-struni/Lib/urllib.py	(original)
+++ python/branches/py3k-struni/Lib/urllib.py	Fri May 18 02:51:22 2007
@@ -462,10 +462,7 @@
     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 @@
         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 @@
         # 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 @@
     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

Modified: python/branches/py3k-struni/Lib/urllib2.py
==============================================================================
--- python/branches/py3k-struni/Lib/urllib2.py	(original)
+++ python/branches/py3k-struni/Lib/urllib2.py	Fri May 18 02:51:22 2007
@@ -101,10 +101,7 @@
 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,

Modified: python/branches/py3k-struni/Lib/urlparse.py
==============================================================================
--- python/branches/py3k-struni/Lib/urlparse.py	(original)
+++ python/branches/py3k-struni/Lib/urlparse.py	Fri May 18 02:51:22 2007
@@ -350,10 +350,7 @@
         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()

Modified: python/branches/py3k-struni/Lib/xdrlib.py
==============================================================================
--- python/branches/py3k-struni/Lib/xdrlib.py	(original)
+++ python/branches/py3k-struni/Lib/xdrlib.py	Fri May 18 02:51:22 2007
@@ -5,10 +5,7 @@
 """
 
 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"]
 

Modified: python/branches/py3k-struni/Lib/xmlrpclib.py
==============================================================================
--- python/branches/py3k-struni/Lib/xmlrpclib.py	(original)
+++ python/branches/py3k-struni/Lib/xmlrpclib.py	Fri May 18 02:51:22 2007
@@ -370,10 +370,7 @@
 # @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 @@
 
     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):

Modified: python/branches/py3k-struni/Lib/zipfile.py
==============================================================================
--- python/branches/py3k-struni/Lib/zipfile.py	(original)
+++ python/branches/py3k-struni/Lib/zipfile.py	Fri May 18 02:51:22 2007
@@ -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 @@
         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)


More information about the Python-3000-checkins mailing list