Skip to content

gh-131684: Ignore unittest.SkipTest in pkgutil.walk_packages#148926

Closed
RezSat wants to merge 1 commit intopython:mainfrom
RezSat:gh-131684-pkgutil-skiptest
Closed

gh-131684: Ignore unittest.SkipTest in pkgutil.walk_packages#148926
RezSat wants to merge 1 commit intopython:mainfrom
RezSat:gh-131684-pkgutil-skiptest

Conversation

@RezSat
Copy link
Copy Markdown

@RezSat RezSat commented Apr 23, 2026

Fixes gh-131684.

pkgutil.walk_packages() currently ignores ImportError by default but still
propagates unittest.SkipTest raised during package imports when no onerror
callback is provided.

This change makes walk_packages() ignore unittest.SkipTest by default in
that case so iteration can continue.

Also added a regression test in Lib/test/test_pkgutil.py and a NEWS entry.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Apr 23, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@picnixz
Copy link
Copy Markdown
Member

picnixz commented Apr 24, 2026

Closing for now because I do not think it is correct. Skipping side-effects (caused by the test package) because a root was not specified is IMO not the correct solution, rather it is right to not silently skip the exception.

@picnixz picnixz closed this Apr 24, 2026
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.

pkgutil.walk_packages(None) imports tests and then their SkipTest exceptions ends iteration

2 participants