From 7adb103e52170a38c41f726f598b968f5ab66ba4 2013-09-30 08:00:20
From: David Österberg <davost@gmail.com>
Date: 2013-09-30 08:00:20
Subject: [PATCH] Change to encodestring to b64encode to avoid newlines in the data URI

The point of this is to improve compatibility with older browsers.
also, encodestring is depricated in python 3.

---

diff --git a/IPython/lib/display.py b/IPython/lib/display.py
index a619515..243f9de 100644
--- a/IPython/lib/display.py
+++ b/IPython/lib/display.py
@@ -138,7 +138,9 @@ class Audio(DisplayObject):
     def src_attr(self):
         import base64
         if self.embed and (self.data is not None):
-                return """data:{type};base64,{base64}""".format(type=self.mimetype, base64=base64.encodestring(self.data))
+            data = base64=base64.b64encode(self.data).decode('ascii'))
+            return """data:{type};base64,{base64}""".format(type=self.mimetype,
+                                                            base64=data)
         elif self.url is not None:
             return self.url
         else: