Skip to content

Commit

Permalink
Tolerate IOBase objects without name attribute
Browse files Browse the repository at this point in the history
BytesIO/StringIO don't have this attribute unless explicitly assigned
  • Loading branch information
dlenski committed Dec 13, 2024
1 parent 9142ab9 commit b89e734
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion zxing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b89e734

Please sign in to comment.