Skip to content

snagflash: fix crash when flashing a bz2 image with a bmap file - #111

Merged
rgantois merged 1 commit into
bootlin:mainfrom
kmaincent:fix_bz2
Nov 2, 2026
Merged

rgantois merged 1 commit into
bootlin:mainfrom
kmaincent:fix_bz2

Conversation

@kmaincent

Copy link
Copy Markdown
Contributor

The BZ2File class does not expose a "name" attribute before Python 3.13, unlike GzipFile which always had one. This leads to the following crash when flashing a bzip2-compressed image with a bmap file on Python < 3.13:

File "snagflash/bmaptools/BmapCopy.py", line 192, in init
self._image_path = image.name
AttributeError: 'BZ2File' object has no attribute 'name'

Fix it by falling back to a generic description when the file object has no "name" attribute. _image_path is only used in log and error messages, so this does not change any behavior for regular files.

Assisted-by: opencode (GLM Flash)

@kmaincent
kmaincent requested a review from rgantois October 28, 2026 14:40
@kmaincent kmaincent self-assigned this Oct 28, 2026
The BZ2File class does not expose a "name" attribute before Python 3.13,
unlike GzipFile which always had one. This leads to the following crash
when flashing a bzip2-compressed image with a bmap file on Python < 3.13:

  File "snagflash/bmaptools/BmapCopy.py", line 192, in __init__
    self._image_path = image.name
  AttributeError: 'BZ2File' object has no attribute 'name'

Fix it by falling back to a generic description when the file object
has no "name" attribute. _image_path is only used in log and error
messages, so this does not change any behavior for regular files.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Assisted-by: opencode (GLM Flash)
@kmaincent kmaincent changed the title snagflash: fix crash when flashing a compressed image with a bmap file snagflash: fix crash when flashing a bz2 image with a bmap file Oct 28, 2026
@rgantois

rgantois commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks a lot!

@rgantois
rgantois merged commit a86aa42 into bootlin:main Nov 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants