Permalink
Browse files

Fix pickle compatibility issue between python 2 and 3

  • Loading branch information...
1 parent d529c67 commit 314d647b80d70d3cdd982fd1eb0a39fbe1881040 @count0 committed Oct 16, 2014
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/graph_tool/io.py
@@ -23,6 +23,7 @@
import pickle
import base64
import atexit
+import sys
from io import BytesIO
from . import libgraph_tool_core
@@ -70,7 +71,9 @@ def pickler(stream, obj):
def unpickler(stream):
data = stream.read()
sstream = BytesIO(data)
- return pickle.load(sstream)
+ if sys.version_info < (3,):
+ return pickle.load(sstream)
+ return pickle.load(sstream, encoding="bytes")
libgraph_tool_core.set_pickler(pickler)
libgraph_tool_core.set_unpickler(unpickler)

0 comments on commit 314d647

Please sign in to comment.