diff options
author | Michael Williamson <mike@zwobble.org> | 2013-09-29 00:49:16 +0100 |
---|---|---|
committer | Michael Williamson <mike@zwobble.org> | 2014-09-07 18:15:16 +0100 |
commit | 979838040f9ff2f52e369812be87f0c7c9c1a0db (patch) | |
tree | 8844108f454c11f463d42d9cbc55a2220165e9c4 /paramiko/sftp_file.py | |
parent | ec9f8a26d4ea77ce6e4a1afe1a9e3b29dbf002bf (diff) | |
download | paramiko-979838040f9ff2f52e369812be87f0c7c9c1a0db.tar.gz |
Introduce ClosingContextManager for classes that already implement close()
Diffstat (limited to 'paramiko/sftp_file.py')
-rw-r--r-- | paramiko/sftp_file.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index 03d67b33..e0fb2297 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -34,9 +34,10 @@ from paramiko.py3compat import long from paramiko.sftp import CMD_CLOSE, CMD_READ, CMD_DATA, SFTPError, CMD_WRITE, \ CMD_STATUS, CMD_FSTAT, CMD_ATTRS, CMD_FSETSTAT, CMD_EXTENDED from paramiko.sftp_attr import SFTPAttributes +from paramiko.util import ClosingContextManager -class SFTPFile (BufferedFile): +class SFTPFile (BufferedFile, ClosingContextManager): """ Proxy object for a file on the remote server, in client mode SFTP. @@ -488,9 +489,3 @@ class SFTPFile (BufferedFile): x = self._saved_exception self._saved_exception = None raise x - - def __enter__(self): - return self - - def __exit__(self, type, value, traceback): - self.close() |