diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2013-02-27 15:56:09 -0800 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2013-02-27 15:56:09 -0800 |
commit | 8e697988af494f4cd499911c9a15ee25d6e2a492 (patch) | |
tree | 77ab569733b4f492b7d54127caf81a5caccf87ec | |
parent | a69abd46067743c965c4eb687fc2b4a52f9b57b5 (diff) |
Changelog + docs re #127
-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 |