Skip to content

Commit 33776a8

Browse files
author
Ryan Hughes
committed
closed file in upload_from_path
The file no longer remains open after calling upload_from_path(). This would previously throw warnings.
1 parent 534c2c8 commit 33776a8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

imgurpython/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,13 @@ def upload_from_path(self, path, config=None, anon=True):
586586
fd = open(path, 'rb')
587587
contents = fd.read()
588588
b64 = base64.b64encode(contents)
589-
590589
data = {
591590
'image': b64,
592591
'type': 'base64',
593592
}
594-
595593
data.update({meta: config[meta] for meta in set(self.allowed_image_fields).intersection(config.keys())})
594+
fd.close()
595+
596596
return self.make_request('POST', 'upload', data, anon)
597597

598598
def upload_from_url(self, url, config=None, anon=True):

0 commit comments

Comments
 (0)