File tree Expand file tree Collapse file tree 4 files changed +31
-5
lines changed
Expand file tree Collapse file tree 4 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 1+ # encoding: utf-8
2+
3+ """
4+ Provides Python 2/3 compatibility objects
5+ """
6+
7+ from __future__ import (
8+ absolute_import , division , print_function , unicode_literals
9+ )
10+
11+ import sys
12+
13+ # ===========================================================================
14+ # Python 3 versions
15+ # ===========================================================================
16+
17+ if sys .version_info >= (3 , 0 ):
18+
19+ from io import BytesIO
20+
21+ # ===========================================================================
22+ # Python 2 versions
23+ # ===========================================================================
24+
25+ else :
26+
27+ from StringIO import StringIO as BytesIO # noqa
Original file line number Diff line number Diff line change 1616except ImportError :
1717 import Image as PIL_Image
1818
19- from StringIO import StringIO
20-
19+ from docx .compat import BytesIO
2120from docx .opc .constants import CONTENT_TYPE as CT
2221from docx .opc .package import Part
2322from docx .shared import Emu , Inches , lazyproperty
@@ -72,7 +71,7 @@ def filename(self):
7271
7372 @classmethod
7473 def from_blob (cls , blob ):
75- stream = StringIO (blob )
74+ stream = BytesIO (blob )
7675 return cls ._from_stream (stream , blob )
7776
7877 @classmethod
@@ -85,7 +84,7 @@ def from_file(cls, image_descriptor):
8584 path = image_descriptor
8685 with open (path , 'rb' ) as f :
8786 blob = f .read ()
88- stream = StringIO (blob )
87+ stream = BytesIO (blob )
8988 filename = os .path .basename (path )
9089 else :
9190 stream = image_descriptor
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ def text_of(relpath):
1515 file_path = os .path .join (thisdir , os .path .normpath (relpath ))
1616 with open (file_path ) as f :
1717 text = f .read ()
18- text .decode ('ascii' ) # result discarded, just make sure no non-ascii chars
1918 return text
2019
2120# Read the version from docx.__version__ without importing the package
Original file line number Diff line number Diff line change 2323 lxml
2424 mock
2525 pytest
26+ Pillow
2627
2728commands =
2829 py.test -qx
You can’t perform that action at this time.
0 commit comments