1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
From bdec8b8ea705cb56440afef565bb36af88ad50e2 Mon Sep 17 00:00:00 2001
From: Hugo Lefeuvre <hle@debian.org>
Date: Tue, 22 Jan 2019 21:51:12 +0100
Subject: Fix AttributeError when plotting graph inline in jupyter notebook.
Origin: upstream
Bug-Debian: https://bugs.debian.org/862054
Applied-Upstream: https://github.com/igraph/python-igraph/commit/8864b46849b031a3013764d03e167222963c0f5d
---
igraph/drawing/__init__.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/igraph/drawing/__init__.py b/igraph/drawing/__init__.py
index 1a232fa..b07a3b3 100644
--- a/igraph/drawing/__init__.py
+++ b/igraph/drawing/__init__.py
@@ -14,7 +14,6 @@ I'm not linking to it :)).
from __future__ import with_statement
-from cStringIO import StringIO
from warnings import warn
import os
@@ -351,7 +350,11 @@ class Plot(object):
context.show_page()
surface.finish()
# Return the raw SVG representation
- return io.getvalue().encode("utf-8")
+ result = io.getvalue()
+ if hasattr(result, "encode"):
+ return result.encode("utf-8") # for Python 2.x
+ else:
+ return result.decode("utf-8") # for Python 3.x
@property
def bounding_box(self):
|