From: Serhiy Storchaka <storchaka@gmail.com> Date: Tue, 8 Mar 2016 16:35:19 +0000 (+0200) Subject: Issue #15068: Got rid of excessive buffering in fileinput. X-Git-Tag: v3.6.0a1~513 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=674e2d0ea05dac2dbcd7156ffb229066aa8acc17;p=python Issue #15068: Got rid of excessive buffering in fileinput. The bufsize parameter is now deprecated and ignored. --- 674e2d0ea05dac2dbcd7156ffb229066aa8acc17 diff --cc Doc/library/fileinput.rst index ee06830ad8,9510f76332..6ca4008399 --- a/Doc/library/fileinput.rst +++ b/Doc/library/fileinput.rst @@@ -71,6 -71,9 +71,8 @@@ The following function is the primary i .. versionchanged:: 3.2 Can be used as a context manager. - .. versionchanged:: 3.5.2 - The *bufsize* parameter is no longer used. - ++ .. deprecated-removed:: 3.6 3.8 ++ The *bufsize* parameter. The following functions use the global state created by :func:`fileinput.input`; if there is no active state, :exc:`RuntimeError` is raised. @@@ -161,7 -164,10 +163,10 @@@ available for subclassing as well Can be used as a context manager. .. deprecated:: 3.4 - The ``'rU'`` and ``'U'`` modes. + The ``'rU'`` and ``'U'`` modes. + - .. versionchanged:: 3.5.2 - The *bufsize* parameter is no longer used. ++ .. deprecated-removed:: 3.6 3.8 ++ The *bufsize* parameter. **Optional in-place filtering:** if the keyword argument ``inplace=True`` is diff --cc Lib/fileinput.py index 3543653f26,9f14762db0..4286156991 --- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@@ -87,8 -79,9 +80,6 @@@ __all__ = ["input", "close", "nextfile" _state = None -# No longer used --DEFAULT_BUFSIZE = 8*1024 -- def input(files=None, inplace=False, backup="", bufsize=0, mode="r", openhook=None): """Return an instance of the FileInput class, which can be iterated. @@@ -208,7 -201,6 +199,10 @@@ class FileInput self._files = files self._inplace = inplace self._backup = backup - self._bufsize = bufsize or DEFAULT_BUFSIZE ++ if bufsize: ++ import warnings ++ warnings.warn('bufsize is deprecated and ignored', ++ DeprecationWarning, stacklevel=2) self._savestdout = None self._output = None self._filename = None diff --cc Lib/test/test_fileinput.py index ad8130468b,784bc92d23..bdf4252d8d --- a/Lib/test/test_fileinput.py +++ b/Lib/test/test_fileinput.py @@@ -57,7 -92,7 +93,11 @@@ class BufferSizesTests(unittest.TestCas t2 = writeTmp(2, ["Line %s of file 2\n" % (i+1) for i in range(10)]) t3 = writeTmp(3, ["Line %s of file 3\n" % (i+1) for i in range(5)]) t4 = writeTmp(4, ["Line %s of file 4\n" % (i+1) for i in range(1)]) -- self.buffer_size_test(t1, t2, t3, t4, bs, round) ++ if bs: ++ with self.assertWarns(DeprecationWarning): ++ self.buffer_size_test(t1, t2, t3, t4, bs, round) ++ else: ++ self.buffer_size_test(t1, t2, t3, t4, bs, round) finally: remove_tempfiles(t1, t2, t3, t4) @@@ -914,12 -981,5 +986,11 @@@ class Test_hook_encoded(unittest.TestCa check('rb', ['A\n', 'B\r\n', 'C\r', 'D\u20ac']) +class MiscTest(unittest.TestCase): + + def test_all(self): - blacklist = {'DEFAULT_BUFSIZE'} - support.check__all__(self, fileinput, blacklist=blacklist) ++ support.check__all__(self, fileinput) + + if __name__ == "__main__": unittest.main() diff --cc Misc/NEWS index 734c967aca,e88938ca53..cb04c90fd0 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -201,8 -90,9 +201,11 @@@ Core and Builtin Library ------- -- Issue #15068: Got rid of excessive buffering in the fileinput module. - The bufsize parameter is no longer used. ++- Issue #15068: Got rid of excessive buffering in fileinput. ++ The bufsize parameter is now deprecated and ignored. ++ +- Issue #19475: Added an optional argument timespec to the datetime + isoformat() method to choose the precision of the time component. - Issue #2202: Fix UnboundLocalError in AbstractDigestAuthHandler.get_algorithm_impls. Initial patch by Mathieu Dupuy.