-
Notifications
You must be signed in to change notification settings - Fork 15
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
Use with statements for handling files #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Hey, this PR is not correct and it breaks things even more :(. The with open(binary, 'rb') as f:
files['binary'] = f
return self._post_data(self.url, data, files) The Here is an example that shows this issue, ran in an ipython interactive shell:
So TL;DR: the post/get/etc call needs to be within the A more robust solution could be to write our own context manager which would do the open/close of the file if its needed (conditionally included in the context manager?). |
Fix #31 - close file handles when we are dealing with local files.