From 8ba44f2099f8971cd8885c8bc3786ca2455157f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=81uszczyk?= Date: Fri, 21 Oct 2016 21:35:39 +0200 Subject: [PATCH] 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. --- PyPDF2/merger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyPDF2/merger.py b/PyPDF2/merger.py index 27702ad..c3373e4 100644 --- a/PyPDF2/merger.py +++ b/PyPDF2/merger.py @@ -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)