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

gh-159693: Format import errors with no usable search paths by limadog9 · Pull Request #159830 · python/cpython · GitHub

Repository navigation

gh-159693: Format import errors with no usable search paths - #159830

Open
limadog9 wants to merge 1 commit into
python:mainfrom
limadog9:gh-159693-traceback-empty-path
Open

limadog9 wants to merge 1 commit into
python:mainfrom
limadog9:gh-159693-traceback-empty-path

Conversation

limadog9 commented Oct 20, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Fixes #159693.

When sys.path has no existing directories, the extension-module hint constructs an empty MultiplexedPath and raises FileNotFoundError while formatting the original ModuleNotFoundError.

This also affects the REPL: InteractiveColoredConsole.runcode() calls traceback.format_exception() through its exception hook. I reproduced the secondary exception through that console before the fix and verified that it displays the original import error afterward.

Return without a hint when there are no directories to search. The regression covers both an empty sys.path and a path containing only a nonexistent directory.

Validation on a Linux x86-64 debug build:

  • Both regression cases fail on unmodified main and pass with the fix.
  • ./python -m test -j2 test_traceback test_code test_pyrepl passed (833 test cases, 65 skips).
  • Ruff, NEWS reStructuredText lint, patchcheck, and git diff --check passed.

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.

traceback formatting raises FileNotFoundError with empty sys.path

1 participant


Back | FazBrowse Home | New Git URL