Commit f29ff272 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Replace StringIO by BytesIO in io.py

This fixes a problem with pickling python::object property maps.
parent d058ad14
......@@ -22,7 +22,7 @@ from __future__ import division, absolute_import, print_function
import pickle
import base64
from io import StringIO
from io import BytesIO
from . import libgraph_tool_core
# IStream and OStream need to be tweaked a little to become a real file-like
......@@ -60,13 +60,13 @@ libgraph_tool_core.OStream.write = OStream_write
# define and set the pickler/unpickler functions
def pickler(stream, obj):
sstream = StringIO()
sstream = BytesIO()
pickle.dump(obj, sstream, -1)
stream.write(base64.b64encode(sstream.getvalue()))
def unpickler(stream):
sstream = StringIO(base64.b64decode(stream.read()))
sstream = BytesIO(base64.b64decode(stream.read()))
return pickle.load(sstream)
libgraph_tool_core.set_pickler(pickler)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment