Fix PdfFileMerger for file objects on Python 3.

The previous check was always evaluated to False on Python 3, so I replaced it
with a duck-typing one compatible with both Python versions.
This commit is contained in:
Michał Łuszczyk 2016-10-21 21:35:39 +02:00
parent 4fc7f9d14a
commit 8ba44f2099
1 changed files with 1 additions and 1 deletions

View File

@ -113,7 +113,7 @@ class PdfFileMerger(object):
if isString(fileobj):
fileobj = file(fileobj, 'rb')
my_file = True
elif isinstance(fileobj, file):
elif hasattr(fileobj, "seek") and hasattr(fileobj, "read"):
fileobj.seek(0)
filecontent = fileobj.read()
fileobj = StreamIO(filecontent)