]> granicus.if.org Git - python/commitdiff
Issue #15068: Got rid of excessive buffering in fileinput.
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 8 Mar 2016 16:35:19 +0000 (18:35 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 8 Mar 2016 16:35:19 +0000 (18:35 +0200)
The bufsize parameter is now deprecated and ignored.

1  2 
Doc/library/fileinput.rst
Lib/fileinput.py
Lib/test/test_fileinput.py
Misc/NEWS

index ee06830ad8e7640d22ff9fd8b1c7866d54cbf4e1,9510f763325b9e4a10cb58e4612b5810af7cb3cb..6ca40083992389d42e996a4281ee5bf2689fe39e
@@@ -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
index 3543653f268be48c87f3d7a70b3c0e38e93cbf3b,9f14762db032cb14422a98bc4f8a7717faf2f557..428615699193e422cfc7da7cf0a7c42c4b4a6be3
@@@ -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
index ad8130468b56ab8a7e275b15d7579929646d50e1,784bc92d23c80d6dfc8b550228fcbdfb8e5cbd7d..bdf4252d8dc276ed6ed627a702f9e5cf25b3e28f
@@@ -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'])
  
  
-         blacklist = {'DEFAULT_BUFSIZE'}
-         support.check__all__(self, fileinput, blacklist=blacklist)
 +class MiscTest(unittest.TestCase):
 +
 +    def test_all(self):
++        support.check__all__(self, fileinput)
 +
 +
  if __name__ == "__main__":
      unittest.main()
diff --cc Misc/NEWS
index 734c967aca3735881abf55655048f5f4fb6a8a16,e88938ca538e8c3e4182f8a7cb4b2e89a7361847..cb04c90fd0843a9b9a026b9685a6547a4e84d8e8
+++ 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.