Skip to content

Commit b89e734

Browse files
committed
Tolerate IOBase objects without name attribute
BytesIO/StringIO don't have this attribute unless explicitly assigned
1 parent 9142ab9 commit b89e734

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

zxing/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def decode(self, filenames, try_harder=False, possible_formats=None, pure_barcod
8585
tf.flush()
8686
fn = tf.name
8787
elif isinstance(fn_or_im, IOBase):
88-
tf = NamedTemporaryFile(prefix='temp_', suffix=os.path.splitext(fn_or_im.name)[1] or '.bin')
88+
tf = NamedTemporaryFile(prefix='temp_', suffix=os.path.splitext(getattr(fn_or_im, 'name', ''))[1])
8989
temp_files.append(tf)
9090
tf.write(fn_or_im.read())
9191
tf.flush()

0 commit comments

Comments
 (0)