Skip to content

Conversation

@tausbn
Copy link
Contributor

@tausbn tausbn commented Oct 13, 2025

It seems _ERR_MSG was silently removed in Python 3.14, leading to an ImportError when running the extractor.

To fix this, we explicitly set _ERR_MSG when the existing import fails (using _ERR_MSG_PREFIX which is available in Python 3.14+, along with the bits that make up the difference between this and _ERR_MSG).

It seems `_ERR_MSG` was silently removed in Python 3.14, leading to an
`ImportError` when running the extractor.

To fix this, we explicitly set `_ERR_MSG` when the existing import fails
(using `_ERR_MSG_PREFIX` which is available in Python 3.14+, along with
the bits that make up the difference between this and `_ERR_MSG`).
@tausbn tausbn marked this pull request as ready for review October 13, 2025 14:48
@tausbn tausbn requested a review from a team as a code owner October 13, 2025 14:48
Copilot AI review requested due to automatic review settings October 13, 2025 14:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a Python 3.14 compatibility issue where the extractor crashes with an ImportError due to the removal of _ERR_MSG from Python's importlib._bootstrap module. The fix implements a fallback mechanism that constructs the error message format when the original import fails.

  • Adds compatibility handling for the removed _ERR_MSG constant in Python 3.14
  • Updates the extractor version to reflect the fix
  • Documents the change in the changelog

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
python/extractor/imp.py Implements try/except fallback to construct _ERR_MSG when not available in Python 3.14+
python/extractor/semmle/util.py Bumps extractor version from 7.1.4 to 7.1.5
python/ql/lib/change-notes/2025-10-13-fix-importerror-on-python-3.14.md Documents the Python 3.14 compatibility fix

Copy link
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LPTM

@yoff yoff merged commit ab78f2b into main Oct 13, 2025
15 checks passed
@yoff yoff deleted the tausbn/python-fix-importerror-in-imp branch October 13, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants