summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2016-04-25 10:31:55 -0700
committerJeff Forcier <jeff@bitprophet.org>2016-04-25 10:31:55 -0700
commit86645149c9d066d5fe9222525c8bdf91df7f7de9 (patch)
tree1fa5cf9e7ca383991208ef9eee904549992a13b7
parentaebd59218f0fc622f77fac552abd9ed1f202383a (diff)
parent48ec43b2009ca5fd8b417849fa73af20b43d1c18 (diff)
Merge branch '1.17'
-rw-r--r--paramiko/sftp_file.py18
-rw-r--r--sites/www/changelog.rst5
2 files changed, 22 insertions, 1 deletions
diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py
index f90fa068..fdf667cd 100644
--- a/paramiko/sftp_file.py
+++ b/paramiko/sftp_file.py
@@ -389,7 +389,7 @@ class SFTPFile (BufferedFile):
"""
self.pipelined = pipelined
- def prefetch(self, file_size):
+ def prefetch(self, file_size=None):
"""
Pre-fetch the remaining contents of this file in anticipation of future
`.read` calls. If reading the entire file, pre-fetching can
@@ -401,8 +401,24 @@ class SFTPFile (BufferedFile):
data may be read in a random order (using `.seek`); chunks of the
buffer that haven't been read will continue to be buffered.
+ :param int file_size:
+ When this is ``None`` (the default), this method calls `stat` to
+ determine the remote file size. In some situations, doing so can
+ cause exceptions or hangs (see `#562
+ <https://github.com/paramiko/paramiko/pull/562>`_); as a
+ workaround, one may call `stat` explicitly and pass its value in
+ via this parameter.
+
.. versionadded:: 1.5.1
+ .. versionchanged:: 1.16.0
+ The ``file_size`` parameter was added (with no default value).
+ .. versionchanged:: 1.16.1
+ The ``file_size`` parameter was made optional for backwards
+ compatibility.
"""
+ if file_size is None:
+ file_size = self.stat().st_size;
+
# queue up async reads for the rest of the file
chunks = []
n = self._realpos
diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst
index 65798259..7cca1840 100644
--- a/sites/www/changelog.rst
+++ b/sites/www/changelog.rst
@@ -2,6 +2,11 @@
Changelog
=========
+* :bug:`676` (via :issue:`677`) Fix a backwards incompatibility issue that
+ cropped up in `SFTPFile.prefetch <~paramiko.sftp_file.prefetch>` re: the
+ erroneously non-optional ``file_size`` parameter. Should only affect users
+ who manually call ``prefetch``. Thanks to ``@stevevanhooser`` for catch &
+ patch.
* :feature:`394` Replace PyCrypto with the Python Cryptographic Authority
(PyCA) 'Cryptography' library suite. This improves security, installability,
and performance; adds PyPy support; and much more.