Skip to content

Commit 22527a6

Browse files
committed
pickle: Module produces and consumes bytes.
So, dumps() should return bytes, dump() should be passed binary file, etc.
1 parent 66f147a commit 22527a6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pickle/pickle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ def dump(obj, f, proto=0):
44
f.write(repr(obj))
55

66
def dumps(obj, proto=0):
7-
return repr(obj)
7+
return repr(obj).encode()
88

99
def load(f):
1010
s = f.read()
1111
return loads(s)
1212

1313
def loads(s):
1414
d = {}
15+
s = s.decode()
1516
if "(" in s:
1617
qualname = s.split("(", 1)[0]
1718
if "." in qualname:

0 commit comments

Comments
 (0)