New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn SFTPFile into a context manager #127

Merged
merged 3 commits into from Feb 27, 2013

Conversation

Projects
None yet
2 participants
@mwilliamson
Contributor

mwilliamson commented Jan 5, 2013

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

@mwilliamson

This comment has been minimized.

Contributor

mwilliamson commented Jan 5, 2013

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

This comment has been minimized.

Contributor

mwilliamson commented Jan 5, 2013

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

This comment has been minimized.

Member

bitprophet commented Feb 27, 2013

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

This comment has been minimized.

Member

bitprophet commented Feb 27, 2013

LGTM. Thanks again!

bitprophet added a commit that referenced this pull request Feb 27, 2013

Merge pull request #127 from mwilliamson/sftp-file-context-manager
Turn SFTPFile into a context manager

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

1 check passed

default The Travis build passed
Details

bitprophet added a commit that referenced this pull request Feb 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment