FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Python: Fix `ImportError` in `imp.py` under Python 3.14 by tausbn · Pull Request #20630 · github/codeql · GitHub

/ codeql Public

Python: Fix ImportError in imp.py under Python 3.14 - #20630

Merged
yoff merged 1 commit into
mainfrom
tausbn/python-fix-importerror-in-imp
Oct 13, 2025
Merged

Python: Fix ImportError in imp.py under Python 3.14#20630
yoff merged 1 commit into
mainfrom
tausbn/python-fix-importerror-in-imp

Conversation

tausbn commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

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 marked this pull request as ready for review October 13, 2025 14:48
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

yoff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LPTM

yoff merged commit ab78f2b into main Oct 13, 2025
15 checks passed
yoff deleted the tausbn/python-fix-importerror-in-imp branch October 13, 2025 15:31
akoeplinger added a commit to akoeplinger/codeql that referenced this pull request Nov 25, 2025
Follow-up to github#20630

The fix didn't fully work since when we raise the ImportError in `find_module` we don't pass a named argument into the format string which causes a `KeyError`.

We need to use a format string without named arguments, like Python 3.13 and earlier did.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL