Issue #18743: Fix references to non-existant "StringIO" module

in docstrings and comments.
This commit is contained in:
Serhiy Storchaka 2013-08-29 11:39:48 +03:00
commit 48e6a8c88a
8 changed files with 15 additions and 24 deletions

View File

@ -69,12 +69,9 @@ class async_chat (asyncore.dispatcher):
# for string terminator matching # for string terminator matching
self.ac_in_buffer = b'' self.ac_in_buffer = b''
# we use a list here rather than cStringIO for a few reasons... # we use a list here rather than io.BytesIO for a few reasons...
# del lst[:] is faster than sio.truncate(0) # del lst[:] is faster than bio.truncate(0)
# lst = [] is faster than sio.truncate(0) # lst = [] is faster than bio.truncate(0)
# cStringIO will be gaining unicode support in py3k, which
# will negatively affect the performance of bytes compared to
# a ''.join() equivalent
self.incoming = [] self.incoming = []
# we toss the use of the "simple producer" and replace it with # we toss the use of the "simple producer" and replace it with

View File

@ -141,7 +141,7 @@ class GzipFile(io.BufferedIOBase):
non-trivial value. non-trivial value.
The new class instance is based on fileobj, which can be a regular The new class instance is based on fileobj, which can be a regular
file, a StringIO object, or any other object which simulates a file. file, an io.BytesIO object, or any other object which simulates a file.
It defaults to None, in which case filename is opened to provide It defaults to None, in which case filename is opened to provide
a file object. a file object.

View File

@ -501,7 +501,7 @@ class SpooledTemporaryFile:
# The method caching trick from NamedTemporaryFile # The method caching trick from NamedTemporaryFile
# won't work here, because _file may change from a # won't work here, because _file may change from a
# _StringIO instance to a real file. So we list # BytesIO/StringIO instance to a real file. So we list
# all the methods directly. # all the methods directly.
# Context management protocol # Context management protocol

View File

@ -1552,14 +1552,14 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
pickler.dump(data) pickler.dump(data)
first_pickled = f.getvalue() first_pickled = f.getvalue()
# Reset StringIO object. # Reset BytesIO object.
f.seek(0) f.seek(0)
f.truncate() f.truncate()
pickler.dump(data) pickler.dump(data)
second_pickled = f.getvalue() second_pickled = f.getvalue()
# Reset the Pickler and StringIO objects. # Reset the Pickler and BytesIO objects.
pickler.clear_memo() pickler.clear_memo()
f.seek(0) f.seek(0)
f.truncate() f.truncate()

View File

@ -53,8 +53,8 @@ class EPipeSocket(FakeSocket):
def close(self): def close(self):
pass pass
class NoEOFStringIO(io.BytesIO): class NoEOFBytesIO(io.BytesIO):
"""Like StringIO, but raises AssertionError on EOF. """Like BytesIO, but raises AssertionError on EOF.
This is used below to test that http.client doesn't try to read This is used below to test that http.client doesn't try to read
more from the underlying file than it should. more from the underlying file than it should.
@ -326,7 +326,7 @@ class BasicTest(TestCase):
'HTTP/1.1 200 OK\r\n' 'HTTP/1.1 200 OK\r\n'
'Content-Length: 14432\r\n' 'Content-Length: 14432\r\n'
'\r\n', '\r\n',
NoEOFStringIO) NoEOFBytesIO)
resp = client.HTTPResponse(sock, method="HEAD") resp = client.HTTPResponse(sock, method="HEAD")
resp.begin() resp.begin()
if resp.read(): if resp.read():
@ -339,7 +339,7 @@ class BasicTest(TestCase):
'HTTP/1.1 200 OK\r\n' 'HTTP/1.1 200 OK\r\n'
'Content-Length: 14432\r\n' 'Content-Length: 14432\r\n'
'\r\n', '\r\n',
NoEOFStringIO) NoEOFBytesIO)
resp = client.HTTPResponse(sock, method="HEAD") resp = client.HTTPResponse(sock, method="HEAD")
resp.begin() resp.begin()
b = bytearray(5) b = bytearray(5)

View File

@ -160,15 +160,7 @@ class BaseTest(unittest.TestCase):
the expected_values list of tuples.""" the expected_values list of tuples."""
stream = stream or self.stream stream = stream or self.stream
pat = re.compile(pat or self.expected_log_pat) pat = re.compile(pat or self.expected_log_pat)
try: actual_lines = stream.getvalue().splitlines()
if hasattr(stream, 'reset'):
stream.reset()
elif hasattr(stream, 'seek'):
stream.seek(0)
actual_lines = stream.readlines()
except AttributeError:
# StringIO.StringIO lacks a reset() method.
actual_lines = stream.getvalue().splitlines()
self.assertEqual(len(actual_lines), len(expected_values)) self.assertEqual(len(actual_lines), len(expected_values))
for actual, expected in zip(actual_lines, expected_values): for actual, expected in zip(actual_lines, expected_values):
match = pat.search(actual) match = pat.search(actual)

View File

@ -160,6 +160,8 @@ Tests
Documentation Documentation
------------- -------------
- Issue #18743: Fix references to non-existant "StringIO" module.
- Issue #18783: Removed existing mentions of Python long type in docstrings, - Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments. error messages and comments.

View File

@ -121,7 +121,7 @@ class StringTruncated(RuntimeError):
pass pass
class TruncatedStringIO(object): class TruncatedStringIO(object):
'''Similar to cStringIO, but can truncate the output by raising a '''Similar to io.StringIO, but can truncate the output by raising a
StringTruncated exception''' StringTruncated exception'''
def __init__(self, maxlen=None): def __init__(self, maxlen=None):
self._val = '' self._val = ''