Replace removed pkgutil.get_loader with importlib.util.find_spec in get_fullname#1998
Merged
Replace removed pkgutil.get_loader with importlib.util.find_spec in get_fullname#1998
Conversation
…kgutil.get_loader pkgutil.get_loader() was removed in Python 3.14, causing subprocess module execution to fail with "No module named" when subProcess: true. Replace with importlib.util.find_spec() which is the recommended replacement and works across all supported Python versions. Co-authored-by: rchiodo <19672699+rchiodo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix inability to run Python module in subprocess
Replace removed pkgutil.get_loader with importlib.util.find_spec in get_fullname
Feb 23, 2026
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
rchiodo
approved these changes
Feb 23, 2026
StellaHuang95
approved these changes
Feb 23, 2026
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pkgutil.get_loader()was removed in Python 3.14, causingget_fullname()to silently returnNonefor all module lookups. WhensubProcess: true, debugpy intercepts subprocess calls and usesget_fullname()to resolve-m <module>targets. The silent failure cascades to "No module named ..." for any single-file module run viasubprocess.run([sys.executable, "-m", "mod"]).Changes
pydevd_file_utils.py: Replacepkgutil.get_loader()withimportlib.util.find_spec(), checkingspec.has_locationto exclude built-in/frozen module origins (e.g."built-in","frozen") that aren't file pathstest_convert_utilities.py: Add regression test forget_fullname()covering single-file modules, packages, and nonexistent modulesOriginal prompt
subProcess: true#1997🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.