File: 0001-Fix-AttributeError-when-plotting-graph-inline-in-jup.patch

package info (click to toggle)
python-igraph 0.7.1.post6-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,360 kB
  • sloc: ansic: 20,069; python: 14,114; sh: 56; makefile: 13
file content (37 lines) | stat: -rw-r--r-- 1,265 bytes parent folder | download
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):