From 75eaeff70de3490dd0817d932f5bfb46a22137dc Mon Sep 17 00:00:00 2001 From: Julian Wachholz Date: Mon, 18 Jul 2016 13:16:59 +0200 Subject: [PATCH] Make sure to close file handle when saving workbook --- pyexcelerate/Workbook.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyexcelerate/Workbook.py b/pyexcelerate/Workbook.py index 4a2bc89..f01f712 100644 --- a/pyexcelerate/Workbook.py +++ b/pyexcelerate/Workbook.py @@ -78,4 +78,5 @@ def _save(self, file_handle): self._writer.save(file_handle) def save(self, filename): - self._save(open(filename, 'wb')) + with open(filename, 'wb') as fp: + self._save(fp)