##// END OF EJS Templates
Backport PR #2778: P3K: fix DeprecationWarning under Python 3.x...
MinRK -
Show More
@@ -15,9 +15,15 b' import math'
15 15 import re
16 16 import sys
17 17 import types
18 from base64 import encodestring
19 18 from datetime import datetime
20 19
20 try:
21 # base64.encodestring is deprecated in Python 3.x
22 from base64 import encodebytes
23 except ImportError:
24 # Python 2.x
25 from base64 import encodestring as encodebytes
26
21 27 from IPython.utils import py3compat
22 28 from IPython.utils.encoding import DEFAULT_ENCODING
23 29 from IPython.utils import text
@@ -118,10 +124,10 b' def encode_images(format_dict):'
118 124 encoded = format_dict.copy()
119 125 pngdata = format_dict.get('image/png')
120 126 if isinstance(pngdata, bytes) and pngdata[:8] == PNG:
121 encoded['image/png'] = encodestring(pngdata).decode('ascii')
127 encoded['image/png'] = encodebytes(pngdata).decode('ascii')
122 128 jpegdata = format_dict.get('image/jpeg')
123 129 if isinstance(jpegdata, bytes) and jpegdata[:2] == JPEG:
124 encoded['image/jpeg'] = encodestring(jpegdata).decode('ascii')
130 encoded['image/jpeg'] = encodebytes(jpegdata).decode('ascii')
125 131 return encoded
126 132
127 133
General Comments 0
You need to be logged in to leave comments. Login now