diff --git a/IrcMiRCARTBot.py b/IrcMiRCARTBot.py index b028c43..304cd97 100755 --- a/IrcMiRCARTBot.py +++ b/IrcMiRCARTBot.py @@ -180,7 +180,8 @@ class IrcMiRCARTBot(IrcClient.IrcClient): # }}} # {{{ _uploadToImgur(self, imgFilePath, imgName, imgTitle, apiKey): Upload single file to Imgur def _uploadToImgur(self, imgFilePath, imgName, imgTitle, apiKey): - requestImageData = open(imgFilePath, "rb").read() + with open(imgFilePath, "rb") as requestImage: + requestImageData = requestImage.read() requestData = { \ "image": base64.b64encode(requestImageData), \ "key": apiKey, \ diff --git a/MiRCARTCanvasExportStore.py b/MiRCARTCanvasExportStore.py index e7c520d..f8e7035 100644 --- a/MiRCARTCanvasExportStore.py +++ b/MiRCARTCanvasExportStore.py @@ -42,7 +42,8 @@ class MiRCARTCanvasExportStore(): # {{{ _exportFileToImgur(self, apiKey, imgName, imgTitle, pathName): upload single PNG file to Imgur def _exportFileToImgur(self, apiKey, imgName, imgTitle, pathName): - requestImageData = open(pathName, "rb").read() + with open(pathName, "rb") as requestImage: + requestImageData = requestImage.read() requestData = { \ "image": base64.b64encode(requestImageData), \ "key": apiKey, \