Skip to content

Commit 073dfd2

Browse files
committed
fix file streaming examples in docs to open file in binary mode
for python 3.
1 parent 234d380 commit 073dfd2

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ A more complicated example:
4848

4949
Streaming serialization with file-like objects:
5050
``` python
51-
>>> f = open('test.bin', 'w')
51+
>>> f = open('test.bin', 'wb')
5252
>>> umsgpack.pack({u"compact": True, u"schema": 0}, f)
5353
>>> umsgpack.pack([1,2,3], f)
5454
>>> f.close()
5555
>>>
56-
>>> f = open('test.bin')
56+
>>> f = open('test.bin', 'rb')
5757
>>> umsgpack.unpack(f)
5858
{u'compact': True, u'schema': 0}
5959
>>> umsgpack.unpack(f)
@@ -87,11 +87,11 @@ Python standard library style names `dump`, `dumps`, `load`, `loads` are also av
8787
>>> umsgpack.loads(_)
8888
{u'compact': True, u'schema': 0}
8989
>>>
90-
>>> f = open('test.bin', 'w')
90+
>>> f = open('test.bin', 'wb')
9191
>>> umsgpack.dump({u"compact": True, u"schema": 0}, f)
9292
>>> f.close()
9393
>>>
94-
>>> f = open('test.bin')
94+
>>> f = open('test.bin', 'rb')
9595
>>> umsgpack.load(f)
9696
{u'compact': True, u'schema': 0}
9797
>>>

msgpack.org.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ A more complicated example:
4949

5050
Streaming serialization with file-like objects:
5151
``` python
52-
>>> f = open('test.bin', 'w')
52+
>>> f = open('test.bin', 'wb')
5353
>>> umsgpack.pack({u"compact": True, u"schema": 0}, f)
5454
>>> umsgpack.pack([1,2,3], f)
5555
>>> f.close()
5656
>>>
57-
>>> f = open('test.bin')
57+
>>> f = open('test.bin', 'rb')
5858
>>> umsgpack.unpack(f)
5959
{u'compact': True, u'schema': 0}
6060
>>> umsgpack.unpack(f)
@@ -89,11 +89,11 @@ available:
8989
>>> umsgpack.loads(_)
9090
{u'compact': True, u'schema': 0}
9191
>>>
92-
>>> f = open('test.bin', 'w')
92+
>>> f = open('test.bin', 'wb')
9393
>>> umsgpack.dump({u"compact": True, u"schema": 0}, f)
9494
>>> f.close()
9595
>>>
96-
>>> f = open('test.bin')
96+
>>> f = open('test.bin', 'rb')
9797
>>> umsgpack.load(f)
9898
{u'compact': True, u'schema': 0}
9999
>>>

0 commit comments

Comments
 (0)