branch: externals/drepl
commit 079ea9d19d31190f6afdfa8dc28861e8e041ea37
Author: Augusto Stoffel <[email protected]>
Commit: Augusto Stoffel <[email protected]>

    IPython: use the newer base64 API
---
 drepl-ipython.py | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drepl-ipython.py b/drepl-ipython.py
index 03506ef72a..d387179e10 100644
--- a/drepl-ipython.py
+++ b/drepl-ipython.py
@@ -1,6 +1,7 @@
 """IPython interface for dREPL."""
 
 import base64
+from base64 import b64decode, b64encode
 import json
 from itertools import chain
 from pathlib import Path
@@ -14,16 +15,10 @@ from IPython.utils.tokenutil import token_at_cursor
 from traitlets import Unicode
 
 
-def encoding_workaround(data):
-    if isinstance(data, str):
-        return base64.decodebytes(data.encode())
-    return data
-
-
 mime_types = {
     "application/json": lambda d: json.dumps(d).encode(),
-    "image/jpeg": encoding_workaround,
-    "image/png": encoding_workaround,
+    "image/jpeg": lambda s: b64decode(s) if isinstance(s, str) else s,
+    "image/png": lambda s: b64decode(s) if isinstance(s, str) else s,
     "image/svg+xml": str.encode,
     "text/html": str.encode,
     "text/latex": str.encode,

Reply via email to