Skip to content

gh-146358: Fix warnings.catch_warnings on Free Threading#146374

Merged
vstinner merged 3 commits intopython:mainfrom
vstinner:warnings
Mar 25, 2026
Merged

gh-146358: Fix warnings.catch_warnings on Free Threading#146374
vstinner merged 3 commits intopython:mainfrom
vstinner:warnings

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Mar 24, 2026

catch_warnings now also overrides warnings.showwarning() on Free Threading to support custom warnings.showwarning().

catch_warnings now also overrides warnings.showwarning() on Free
Threading to support custom warnings.showwarning().
@vstinner
Copy link
Member Author

cc @nascheme and @kumaraditya303 who added the the context variable to warnings.catch_warnings.

@kumaraditya303
Copy link
Contributor

The tests are failing.

@vstinner
Copy link
Member Author

Ah yes, my test was dependent of filter warnings, and the CI runs the test suite with -Werror. I fixed my test, it does now reset filters.

@vstinner
Copy link
Member Author

@kumaraditya303: I added a test on logging.captureWarnings(True). Please review the updated PR.

Copy link
Contributor

@kumaraditya303 kumaraditya303 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@vstinner vstinner merged commit 0055140 into python:main Mar 25, 2026
50 checks passed
@vstinner vstinner deleted the warnings branch March 25, 2026 13:34
@miss-islington-app
Copy link

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 25, 2026
…nGH-146374)

catch_warnings now also overrides warnings.showwarning() on Free
Threading to support custom warnings.showwarning().
(cherry picked from commit 0055140b2cf3e3a86ef9ab7a39e2083212b27c58)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Mar 25, 2026

GH-146418 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Mar 25, 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.

2 participants