Added check for flush method existense for file-like object in tiffplugin setup

This commit is contained in:
Dmitry Yantsen 2015-08-28 14:59:29 +05:00
parent bbc6f7d6bb
commit a2b6b661d9

View File

@ -935,7 +935,9 @@ class TiffImageFile(ImageFile.ImageFile):
# flush the file descriptor, prevents error on pypy 2.4+
# should also eliminate the need for fp.tell for py3
# in _seek
self.fp.flush()
# flush method may not exist for file-like object.
if hasattr(self.fp, 'flush'):
self.fp.flush()
except IOError:
# io.BytesIO have a fileno, but returns an IOError if
# it doesn't use a file descriptor.