From e75cfa24dfbfe64bc57f43cb944b5f07bf3b879c Mon Sep 17 00:00:00 2001 From: Manuel Riel Date: Mon, 6 Oct 2014 12:50:53 +0200 Subject: [PATCH] make base64 decoding ipython3 compatible --- IPython/html/files/handlers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/IPython/html/files/handlers.py b/IPython/html/files/handlers.py index 7ba667f78..bde2e0989 100644 --- a/IPython/html/files/handlers.py +++ b/IPython/html/files/handlers.py @@ -7,6 +7,8 @@ import logging import os import mimetypes import json +import base64 + try: # py3 from http.client import responses @@ -47,7 +49,8 @@ class FilesHandler(IPythonHandler): self.set_header('Content-Disposition','attachment; filename="%s"' % name) if model['format'] == 'base64': - self.write(model['content'].decode('base64')) + b64_bytes = model['content'].encode('ascii') + self.write(base64.decodestring(b64_bytes)) elif model['format'] == 'json': self.write(json.dumps(model['content'])) else: