From f94684c8ea750c0926951fbd0fe33b8074a648e8 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Thu, 19 Jan 2017 20:32:46 +0100 Subject: [PATCH] If input to convert() doesn't have a write() member, then it must be str or bytes type --- src/img2pdf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/img2pdf.py b/src/img2pdf.py index ce44db0..703d0d3 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -1005,6 +1005,9 @@ def convert(*images, title=None, try: rawdata = img.read() except AttributeError: + if not isinstance(img, (str, bytes)): + raise TypeError( + "Neither implements read() nor is str or bytes") # the thing doesn't have a read() function, so try if we can treat # it as a file name try: