Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/user/documents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ a document like so::
# or

with open('foobar.docx', 'rb') as f:
source_stream = StringIO(f.read())
source_stream = BytesIO(f.read())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, interesting. I'm sure this is an artifact of this documentation being written during the Python 2 era, when StringIO actually meant "read bytes".

I'll put it on the shortlist and fix it up next time I'm in there.

document = Document(source_stream)
source_stream.close()
...
target_stream = StringIO()
target_stream = BytesIO()
document.save(target_stream)

The ``'rb'`` file open mode parameter isn't required on all operating
Expand Down