File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1818
1919 from io import BytesIO
2020
21+ def is_string (obj ):
22+ """
23+ Return True if *obj* is a string, False otherwise.
24+ """
25+ return isinstance (obj , str )
26+
2127# ===========================================================================
2228# Python 2 versions
2329# ===========================================================================
2430
2531else :
2632
2733 from StringIO import StringIO as BytesIO # noqa
34+
35+ def is_string (obj ):
36+ """
37+ Return True if *obj* is a string, False otherwise.
38+ """
39+ return isinstance (obj , basestring )
Original file line number Diff line number Diff line change 1616except ImportError :
1717 import Image as PIL_Image
1818
19- from docx .compat import BytesIO
19+ from docx .compat import BytesIO , is_string
2020from docx .opc .constants import CONTENT_TYPE as CT
2121from docx .opc .package import Part
2222from docx .shared import Emu , Inches , lazyproperty
@@ -80,7 +80,7 @@ def from_file(cls, image_descriptor):
8080 Return a new |Image| instance loaded from the image file identified
8181 by *image_descriptor*, a path or file-like object.
8282 """
83- if isinstance (image_descriptor , basestring ):
83+ if is_string (image_descriptor ):
8484 path = image_descriptor
8585 with open (path , 'rb' ) as f :
8686 blob = f .read ()
You can’t perform that action at this time.
0 commit comments