Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
3424a562
Commit
3424a562
authored
Dec 30, 2012
by
Tiago Peixoto
Browse files
Fix issue with pickling and python3
parent
aa341e2e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/io.py
View file @
3424a562
...
...
@@ -52,7 +52,10 @@ def IStream_readline(self, n=None):
def
OStream_write
(
self
,
s
):
self
.
Write
(
s
,
len
(
s
))
data
=
s
if
not
isinstance
(
data
,
str
)
and
isinstance
(
data
,
bytes
):
data
=
data
.
decode
(
'utf-8'
)
self
.
Write
(
data
,
len
(
s
))
libgraph_tool_core
.
IStream
.
read
=
IStream_read
libgraph_tool_core
.
IStream
.
readline
=
IStream_readline
...
...
@@ -63,11 +66,11 @@ libgraph_tool_core.OStream.write = OStream_write
def
pickler
(
stream
,
obj
):
sstream
=
BytesIO
()
pickle
.
dump
(
obj
,
sstream
,
-
1
)
stream
.
write
(
base64
.
b64encode
(
sstream
.
getvalue
().
encode
(
'ascii'
)))
stream
.
write
(
base64
.
b64encode
(
sstream
.
getvalue
()))
def
unpickler
(
stream
):
sstream
=
BytesIO
(
base64
.
b64decode
(
stream
.
read
().
encode
(
'ascii'
)))
data
=
stream
.
read
().
encode
(
'utf-8'
)
sstream
=
BytesIO
(
base64
.
b64decode
(
data
))
return
pickle
.
load
(
sstream
)
libgraph_tool_core
.
set_pickler
(
pickler
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment