You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
2.2 KiB
52 lines
2.2 KiB
4 years ago
|
From 3b648aab9ce731beab1f02d714a97905ab0e42e1 Mon Sep 17 00:00:00 2001
|
||
|
From: Karthikeyan Singaravelan <tir.karthi@gmail.com>
|
||
|
Date: Thu, 2 Jan 2020 18:30:41 +0530
|
||
|
Subject: [PATCH] Fix deprecation warning in base64
|
||
|
|
||
|
---
|
||
|
jupyter_console/ptshell.py | 6 +++---
|
||
|
jupyter_console/tests/test_image_handler.py | 2 +-
|
||
|
2 files changed, 4 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/jupyter_console/ptshell.py b/jupyter_console/ptshell.py
|
||
|
index 84af32f..6a55fe1 100644
|
||
|
--- a/jupyter_console/ptshell.py
|
||
|
+++ b/jupyter_console/ptshell.py
|
||
|
@@ -818,12 +818,12 @@ def handle_image_PIL(self, data, mime):
|
||
|
from PIL import Image, ImageShow
|
||
|
except ImportError:
|
||
|
return False
|
||
|
- raw = base64.decodestring(data[mime].encode('ascii'))
|
||
|
+ raw = base64.decodebytes(data[mime].encode('ascii'))
|
||
|
img = Image.open(BytesIO(raw))
|
||
|
return ImageShow.show(img)
|
||
|
|
||
|
def handle_image_stream(self, data, mime):
|
||
|
- raw = base64.decodestring(data[mime].encode('ascii'))
|
||
|
+ raw = base64.decodebytes(data[mime].encode('ascii'))
|
||
|
imageformat = self._imagemime[mime]
|
||
|
fmt = dict(format=imageformat)
|
||
|
args = [s.format(**fmt) for s in self.stream_image_handler]
|
||
|
@@ -835,7 +835,7 @@ def handle_image_stream(self, data, mime):
|
||
|
return (proc.returncode == 0)
|
||
|
|
||
|
def handle_image_tempfile(self, data, mime):
|
||
|
- raw = base64.decodestring(data[mime].encode('ascii'))
|
||
|
+ raw = base64.decodebytes(data[mime].encode('ascii'))
|
||
|
imageformat = self._imagemime[mime]
|
||
|
filename = 'tmp.{0}'.format(imageformat)
|
||
|
with NamedFileInTemporaryDirectory(filename) as f, \
|
||
|
diff --git a/jupyter_console/tests/test_image_handler.py b/jupyter_console/tests/test_image_handler.py
|
||
|
index 5296635..b2a5ea9 100644
|
||
|
--- a/jupyter_console/tests/test_image_handler.py
|
||
|
+++ b/jupyter_console/tests/test_image_handler.py
|
||
|
@@ -32,7 +32,7 @@ def setUp(self):
|
||
|
self.shell = NonCommunicatingShell()
|
||
|
self.raw = b'dummy data'
|
||
|
self.mime = 'image/png'
|
||
|
- self.data = {self.mime: base64.encodestring(self.raw).decode('ascii')}
|
||
|
+ self.data = {self.mime: base64.encodebytes(self.raw).decode('ascii')}
|
||
|
|
||
|
def test_call_pil_by_default(self):
|
||
|
pil_called_with = []
|