Turn SFTPFile into a context manager #127

Merged
merged 3 commits into from Feb 27, 2013

Projects

None yet

2 participants

@mwilliamson
Contributor

Allow instances of SFTPFile to be used in with statements by turning it into a context manager.

@mwilliamson
Contributor

Hmm, but as the build failure points out, just checking for Python version in the tests isn't sufficient since it's a syntax in 2.5 without:

from __future__ import with_statement

And presumably it'll just always fail in Python 2.4. Should it be possible to run the tests successfully on Python 2.4? The actual code should still work fine since it's just adding two methods that'll never get called.

@mwilliamson
Contributor

If the tests need to pass on Python 2.4, then one possibility is to have a separate module for testing this feature, and conditionally import that module in test.py.

@bitprophet
Member

At this point I'm not supporting Paramiko on anything older than 2.5, so no worries about that.

Thanks for the submission, will take a look soon hopefully. Also, noting for linkage that this is related to #38.

@bitprophet
Member

LGTM. Thanks again!

@bitprophet bitprophet merged commit a69abd4 into paramiko:master Feb 27, 2013

1 check passed

default The Travis build passed
Details
@bitprophet bitprophet added a commit that referenced this pull request Feb 27, 2013
@bitprophet bitprophet Changelog + docs re #127 8e69798
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment