Skip to content

Commit 68937b4

Browse files
committed
Change some uses of cStringIO.StringIO to io.StringIO.
This is undoubtedly insufficient and in some cases just as broken as before.
1 parent 7ac9d40 commit 68937b4

19 files changed

Lines changed: 26 additions & 89 deletions

Lib/SimpleHTTPServer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
import cgi
1919
import shutil
2020
import mimetypes
21-
try:
22-
from cStringIO import StringIO
23-
except ImportError:
24-
from StringIO import StringIO
21+
from io import StringIO
2522

2623

2724
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):

Lib/SocketServer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,7 @@ class DatagramRequestHandler(BaseRequestHandler):
577577
"""Define self.rfile and self.wfile for datagram sockets."""
578578

579579
def setup(self):
580-
try:
581-
from cStringIO import StringIO
582-
except ImportError:
583-
from StringIO import StringIO
580+
from io import StringIO
584581
self.packet, self.socket = self.request
585582
self.rfile = StringIO(self.packet)
586583
self.wfile = StringIO()

Lib/cgi.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@
4141
import mimetools
4242
import rfc822
4343
import UserDict
44-
try:
45-
from cStringIO import StringIO
46-
except ImportError:
47-
from StringIO import StringIO
44+
from io import StringIO
4845

4946
__all__ = ["MiniFieldStorage", "FieldStorage", "FormContentDict",
5047
"SvFormContentDict", "InterpFormContentDict", "FormContent",

Lib/csv.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
__doc__
1212
from _csv import Dialect as _Dialect
1313

14-
try:
15-
from cStringIO import StringIO
16-
except ImportError:
17-
from StringIO import StringIO
14+
from io import StringIO
1815

1916
__all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
2017
"Error", "Dialect", "excel", "excel_tab", "reader", "writer",

Lib/gettext.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ def c2py(plural):
7777
Python lambda function that implements an equivalent expression.
7878
"""
7979
# Security check, allow only the "n" identifier
80-
try:
81-
from cStringIO import StringIO
82-
except ImportError:
83-
from StringIO import StringIO
80+
from io import StringIO
8481
import token, tokenize
8582
tokens = tokenize.generate_tokens(StringIO(plural).readline)
8683
try:

Lib/httplib.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@
7171
import socket
7272
from urlparse import urlsplit
7373

74-
try:
75-
from cStringIO import StringIO
76-
except ImportError:
77-
from StringIO import StringIO
74+
from io import StringIO
7875

7976
__all__ = ["HTTP", "HTTPResponse", "HTTPConnection", "HTTPSConnection",
8077
"HTTPException", "NotConnected", "UnknownProtocol",

Lib/mhlib.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,7 @@ def getbodytext(self, decode = 1):
697697
encoding = self.getencoding()
698698
if not decode or encoding in ('', '7bit', '8bit', 'binary'):
699699
return self.fp.read()
700-
try:
701-
from cStringIO import StringIO
702-
except ImportError:
703-
from StringIO import StringIO
700+
from io import StringIO
704701
output = StringIO()
705702
mimetools.decode(self.fp, output, encoding)
706703
return output.getvalue()

Lib/quopri.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def write(s, output=output, lineEnd='\n'):
105105
def encodestring(s, quotetabs = 0, header = 0):
106106
if b2a_qp is not None:
107107
return b2a_qp(s, quotetabs = quotetabs, header = header)
108-
from cStringIO import StringIO
108+
from io import StringIO
109109
infp = StringIO(s)
110110
outfp = StringIO()
111111
encode(infp, outfp, quotetabs, header)
@@ -159,7 +159,7 @@ def decode(input, output, header = 0):
159159
def decodestring(s, header = 0):
160160
if a2b_qp is not None:
161161
return a2b_qp(s, header = header)
162-
from cStringIO import StringIO
162+
from io import StringIO
163163
infp = StringIO(s)
164164
outfp = StringIO()
165165
decode(infp, outfp, header = header)

Lib/shelve.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,8 @@
5656
the persistent dictionary on disk, if feasible).
5757
"""
5858

59-
# Try using cPickle and cStringIO if available.
60-
61-
try:
62-
from cPickle import Pickler, Unpickler
63-
except ImportError:
64-
from pickle import Pickler, Unpickler
65-
66-
try:
67-
from cStringIO import StringIO
68-
except ImportError:
69-
from StringIO import StringIO
59+
from pickle import Pickler, Unpickler
60+
from io import StringIO
7061

7162
import UserDict
7263
import warnings

Lib/shlex.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
import sys
1212
from collections import deque
1313

14-
try:
15-
from cStringIO import StringIO
16-
except ImportError:
17-
from StringIO import StringIO
14+
from io import StringIO
1815

1916
__all__ = ["shlex", "split"]
2017

0 commit comments

Comments
 (0)