Bug 297235 - security/binwalk: fails to start with python 3.12 due to removed 'imp' module
Summary: security/binwalk: fails to start with python 3.12 due to removed 'imp' module
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Kurt Jaeger
URL:
Keywords:
: 296882 (view as bug list)
Depends on:
Blocks:
 
Reported: 2026-08-02 17:42 UTC by Tales Bragança (Mil3tus)
Modified: 2026-08-02 19:48 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (pi)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tales Bragança (Mil3tus) 2026-08-02 17:42:28 UTC
Environment:

- FreeBSD 14.4-RELEASE amd64
- Python 3.12.13
- security/binwalk 2.3.3_1

Problem:

Binwalk no longer starts under Python 3.12 because it still imports the deprecated 'imp' module, which was removed in Python 3.12.

Running binwalk results in:
ModuleNotFoundError: No module named 'imp'

I prepared and tested a compatibility patch that replaces the deprecated imp implementation with a Python 3.12-compatible alternative.

Validation performed:
- Binwalk starts successfully
- Firmware signature  scanning
- Firmware extraction
- python3 -m compileall

The patch and validation procedure are available here:
https://github.com/Mil3tus/binwalk-python312-freebsd-patch

If useful, I'd be happy to provide additional testing or information.
Comment 1 Kurt Jaeger freebsd_committer freebsd_triage 2026-08-02 19:32:19 UTC
*** Bug 296882 has been marked as a duplicate of this bug. ***
Comment 2 Kurt Jaeger freebsd_committer freebsd_triage 2026-08-02 19:48:17 UTC
Thanks, committed!
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-08-02 19:48:24 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3a09d88ff55ffd98f1df4b3aa6ede2bf3cbc7cd9

commit 3a09d88ff55ffd98f1df4b3aa6ede2bf3cbc7cd9
Author:     Tales Bragança <tales.braganca@icloud.com>
AuthorDate: 2026-08-02 19:43:44 +0000
Commit:     Kurt Jaeger <pi@FreeBSD.org>
CommitDate: 2026-08-02 19:45:50 +0000

    security/binwalk: fix binwalk for use with python3.12

    - replaces the deprecated imp implementation with
      a Python 3.12-compatible alternative.

    PR:             297235
    Source:         https://github.com/Mil3tus/binwalk-python312-freebsd-patch
                    https://github.com/rampageX/firmware-mod-kit/issues/191
    Reported-by:    rodrigo

 .../files/patch-src_binwalk_core_magic.py (new)    | 11 +++
 .../files/patch-src_binwalk_core_module.py (new)   | 45 ++++++++++++
 .../files/patch-src_binwalk_core_plugin.py (new)   | 83 ++++++++++++++++++++++
 3 files changed, 139 insertions(+)