aboutsummaryrefslogtreecommitdiff
path: root/mammoth/conversion.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-14 18:07:19 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-14 18:07:19 +0000
commit0c8ee31a154b5e624f207fb1413295ef2bf45417 (patch)
treefe9c0a681b7c83bd596401d95f480333399f3438 /mammoth/conversion.py
parentecd606c058923c534d1f96fd95110e1edcc70bca (diff)
Support Python 2.6
Diffstat (limited to 'mammoth/conversion.py')
-rw-r--r--mammoth/conversion.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py
index b3b41d0..e21e3a0 100644
--- a/mammoth/conversion.py
+++ b/mammoth/conversion.py
@@ -73,8 +73,11 @@ class DocumentConverter(object):
def _convert_image(self, image, html_generator):
- with image.open() as image_bytes:
+ image_bytes = image.open()
+ try:
encoded_src = base64.b64encode(image_bytes.read()).decode("ascii")
+ finally:
+ image_bytes.close()
attributes = {
"src": "data:{0};base64,{1}".format(image.content_type, encoded_src)