diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | paramiko/sftp_client.py | 2 | ||||
-rw-r--r-- | paramiko/sftp_file.py | 3 |
3 files changed, 6 insertions, 1 deletions
@@ -15,6 +15,8 @@ Releases v1.10.0 (DD MM YYYY) -------------------- +* #127: Turn `SFTPFile` into a context manager. Thanks to Michael Williamson +* for the patch. * #116: Limit `Message.get_bytes` to an upper bound of 1MB to protect against potential DoS vectors. Thanks to `@mvschaik` for catch & patch. * #115: Add convenience `get_pty` kwarg to `Client.exec_command` so users not diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py index 8cb8ceaf..7df643f5 100644 --- a/paramiko/sftp_client.py +++ b/paramiko/sftp_client.py @@ -198,7 +198,7 @@ class SFTPClient (BaseSFTP): Open a file on the remote server. The arguments are the same as for python's built-in C{file} (aka C{open}). A file-like object is returned, which closely mimics the behavior of a normal python file - object. + object, including the ability to be used as a context manager. The mode indicates how the file is to be opened: C{'r'} for reading, C{'w'} for writing (truncating an existing file), C{'a'} for appending, diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index c9fc76f5..d4ecb89f 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -34,6 +34,9 @@ from paramiko.sftp_attr import SFTPAttributes class SFTPFile (BufferedFile): """ Proxy object for a file on the remote server, in client mode SFTP. + + Instances of this class may be used as context managers in the same way + that built-in Python file objects are. """ # Some sftp servers will choke if you send read/write requests larger than |