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

Fix remaining issues with pickling in Python 3

parent b2ed6f34
......@@ -70,7 +70,6 @@ string lexical_cast<string,python::object>(const python::object & o)
stringstream s;
object_pickler(OStream(s), o);
return s.str();
return "";
}
template <>
......@@ -96,7 +95,7 @@ public:
std::streamsize read(char* s, std::streamsize n)
{
python::object pbuf = _file.attr("read")(n);
string buf = python::extract<string>(pbuf);
string buf = python::extract<string>(pbuf.attr("decode")("utf-8"));
for (size_t i = 0; i < buf.size(); ++i)
s[i] = buf[i];
return buf.size();
......@@ -106,7 +105,7 @@ public:
{
string buf(s, s+n);
python::object pbuf(buf);
_file.attr("write")(pbuf);
_file.attr("write")(pbuf.attr("encode")("utf-8"));
return n;
}
......
......@@ -1771,7 +1771,7 @@ class Graph(object):
def __getstate__(self):
state = dict()
sio = BytesIO()
stream = gzip.GzipFile(fileobj=sio, mode="w")
stream = gzip.GzipFile(fileobj=sio, mode="wb")
self.save(stream, "xml")
stream.close()
state["blob"] = sio.getvalue()
......@@ -1782,7 +1782,7 @@ class Graph(object):
blob = state["blob"]
if blob != "":
sio = BytesIO(blob)
stream = gzip.GzipFile(fileobj=sio, mode="r")
stream = gzip.GzipFile(fileobj=sio, mode="rb")
self.load(stream, "xml")
......
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