diff --git a/zxing/__init__.py b/zxing/__init__.py index c95bcbe..ad1ad1f 100644 --- a/zxing/__init__.py +++ b/zxing/__init__.py @@ -85,7 +85,7 @@ def decode(self, filenames, try_harder=False, possible_formats=None, pure_barcod tf.flush() fn = tf.name elif isinstance(fn_or_im, IOBase): - tf = NamedTemporaryFile(prefix='temp_', suffix=os.path.splitext(fn_or_im.name)[1] or '.bin') + tf = NamedTemporaryFile(prefix='temp_', suffix=os.path.splitext(getattr(fn_or_im, 'name', ''))[1]) temp_files.append(tf) tf.write(fn_or_im.read()) tf.flush()