René's URL Explorer Experiment


Title: gh-128384: Add thread-safe context manager to "warnings" module by nascheme · Pull Request #128300 · python/cpython · GitHub

Open Graph Title: gh-128384: Add thread-safe context manager to "warnings" module by nascheme · Pull Request #128300 · python/cpython

X Title: gh-128384: Add thread-safe context manager to "warnings" module by nascheme · Pull Request #128300 · python/cpython

Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.

Open Graph Description: This PR adds a new thread-local (and async friendly) context manager that uses contextvars. The recommended pattern for new code that doesn't care about backwards compatibility would be: with ...

X Description: This PR adds a new thread-local (and async friendly) context manager that uses contextvars. The recommended pattern for new code that doesn't care about backwards compatibility would be: w...

Opengraph URL: https://github.com/python/cpython/pull/128300

X: @github

direct link

Domain: github.com

route-pattern/_view_fragments/voltron/pull_requests/show/:user_id/:repository/:id/pull_request_layout(.:format)
route-controllervoltron_pull_requests_fragments
route-actionpull_request_layout
fetch-noncev2:c54a3306-4ca2-498c-54f5-88b6345b2004
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB49C:209A07:6E2C18:936EE5:6A530156
html-safe-nonce7c91a0d456fc6c58f419468d61bdb317a65b04baea37d8c82b3e061aa2f4e760
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDlDOjIwOUEwNzo2RTJDMTg6OTM2RUU1OjZBNTMwMTU2IiwidmlzaXRvcl9pZCI6IjU0MTA3MDM4ODYwNzQ5NzA0NTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac6443fd64d6abd4de17abf879b6e4d7add2c663e045ca408b231cc7f3170f846f
hovercard-subject-tagpull_request:2253782097
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/pull_requests_fragments/pull_request_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/voltron/pull_requests/show/python/cpython/128300/pull_request_layout
twitter:imagehttps://opengraph.githubassets.com/345d37b4cb700c8c5c8d5b234abec56fef14b69274b5a47f8d32041cf830dfd8/python/cpython/pull/128300
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/345d37b4cb700c8c5c8d5b234abec56fef14b69274b5a47f8d32041cf830dfd8/python/cpython/pull/128300
og:image:altThis PR adds a new thread-local (and async friendly) context manager that uses contextvars. The recommended pattern for new code that doesn't care about backwards compatibility would be: with ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenascheme
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-cache
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/128300#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F128300
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F128300
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fpull_requests_fragments%2Fpull_request_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/128300
Reloadhttps://github.com/python/cpython/pull/128300
Reloadhttps://github.com/python/cpython/pull/128300
Please reload this pagehttps://github.com/python/cpython/pull/128300
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/128300
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
naschemehttps://github.com/nascheme
python:mainhttps://github.com/python/cpython/tree/main
nascheme:warnings_local_contexthttps://github.com/nascheme/cpython/tree/warnings_local_context
Conversationhttps://github.com/python/cpython/pull/128300
Commits9 (9)https://github.com/python/cpython/pull/128300/commits
Checkshttps://github.com/python/cpython/pull/128300/checks
Files changedhttps://github.com/python/cpython/pull/128300/files
gh-128384: Add thread-safe context manager to "warnings" modulehttps://github.com/python/cpython/pull/128300#top
naschemehttps://github.com/nascheme
python:mainhttps://github.com/python/cpython/tree/main
nascheme:warnings_local_contexthttps://github.com/nascheme/cpython/tree/warnings_local_context
https://github.com/nascheme
naschemehttps://github.com/nascheme
Dec 27, 2024https://github.com/python/cpython/pull/128300#issue-2761311880
Please reload this pagehttps://github.com/python/cpython/pull/128300
gh-128209https://github.com/python/cpython/pull/128209
https://cpython-previews--128300.org.readthedocs.build/https://cpython-previews--128300.org.readthedocs.build/
warnings.catch_warnings is not thread safe or async safe #128384https://github.com/python/cpython/issues/128384
Please reload this pagehttps://github.com/python/cpython/pull/128300
https://github.com/nascheme
naschemehttps://github.com/nascheme
force-pushedhttps://github.com/python/cpython/compare/1f8b441ae8452a66159660c422c7b0a6644092dc..3952bb0092bfa5590547397d68a3cc03a7bff2c6
1f8b441https://github.com/python/cpython/commit/1f8b441ae8452a66159660c422c7b0a6644092dc
3952bb0https://github.com/python/cpython/commit/3952bb0092bfa5590547397d68a3cc03a7bff2c6
Compare https://github.com/python/cpython/compare/1f8b441ae8452a66159660c422c7b0a6644092dc..3952bb0092bfa5590547397d68a3cc03a7bff2c6
December 28, 2024 21:07https://github.com/python/cpython/pull/128300#event-15778550205
https://github.com/nascheme
naschemehttps://github.com/nascheme
Dec 31, 2024https://github.com/python/cpython/pull/128300#event-15792172627
https://github.com/apps/bedevere-app
bedevere-apphttps://github.com/apps/bedevere-app
Dec 31, 2024 https://github.com/python/cpython/pull/128300#ref-issue-2764713401
warnings.catch_warnings is not thread safe or async safe #128384 https://github.com/python/cpython/issues/128384
naschemehttps://github.com/nascheme
December 31, 2024 15:24https://github.com/python/cpython/pull/128300#commits-pushed-deb659d
https://github.com/nascheme
Add locking to warnings.py.https://github.com/python/cpython/pull/128300/commits/deb659dd1177e1a537fd25da94576e6e4ea32028
deb659dhttps://github.com/python/cpython/pull/128300/commits/deb659dd1177e1a537fd25da94576e6e4ea32028
https://github.com/nascheme
Add 'context' parameter to Thread.https://github.com/python/cpython/pull/128300/commits/902df7cc238b1060041b87ec22314d2594c92d11
902df7chttps://github.com/python/cpython/pull/128300/commits/902df7cc238b1060041b87ec22314d2594c92d11
https://github.com/nascheme
Make _contextvars a builtin module.https://github.com/python/cpython/pull/128300/commits/e61b40e6a9c3ae226115912e5afce44dc75db9de
e61b40ehttps://github.com/python/cpython/pull/128300/commits/e61b40e6a9c3ae226115912e5afce44dc75db9de
https://github.com/nascheme
wip: warnings local_contexthttps://github.com/python/cpython/pull/128300/commits/3bac8d188cae7e17181f0e206bb9d2f4a75cb8fd
3bac8d1https://github.com/python/cpython/pull/128300/commits/3bac8d188cae7e17181f0e206bb9d2f4a75cb8fd
https://github.com/nascheme
naschemehttps://github.com/nascheme
Dec 31, 2024 https://github.com/python/cpython/pull/128300#ref-pullrequest-2751791157
Switch to a new thread-safe utility for catching warnings. jax-ml/jax#25626 https://github.com/jax-ml/jax/pull/25626
https://github.com/nascheme
naschemehttps://github.com/nascheme
force-pushedhttps://github.com/python/cpython/compare/3952bb0092bfa5590547397d68a3cc03a7bff2c6..3bac8d188cae7e17181f0e206bb9d2f4a75cb8fd
3952bb0https://github.com/python/cpython/commit/3952bb0092bfa5590547397d68a3cc03a7bff2c6
3bac8d1https://github.com/python/cpython/commit/3bac8d188cae7e17181f0e206bb9d2f4a75cb8fd
Compare https://github.com/python/cpython/compare/3952bb0092bfa5590547397d68a3cc03a7bff2c6..3bac8d188cae7e17181f0e206bb9d2f4a75cb8fd
January 1, 2025 05:08https://github.com/python/cpython/pull/128300#event-15792812242
naschemehttps://github.com/nascheme
January 1, 2025 11:47https://github.com/python/cpython/pull/128300#commits-pushed-c7287ad
https://github.com/nascheme
Rename function, add locking to _filters_mutated().https://github.com/python/cpython/pull/128300/commits/c7287ad8a86ae157bae77346656a3de1e0198e3e
c7287adhttps://github.com/python/cpython/pull/128300/commits/c7287ad8a86ae157bae77346656a3de1e0198e3e
https://github.com/nascheme
Use re-entrant lock for warnings module.https://github.com/python/cpython/pull/128300/commits/152127603b0ba7012cb0bb7767a45d7b39b7ec39
1521276https://github.com/python/cpython/pull/128300/commits/152127603b0ba7012cb0bb7767a45d7b39b7ec39
https://github.com/nascheme
Make _warnings use _warnings_context.https://github.com/python/cpython/pull/128300/commits/e5c128a81e882ed7f023c32fd17db5189cb11f59
e5c128ahttps://github.com/python/cpython/pull/128300/commits/e5c128a81e882ed7f023c32fd17db5189cb11f59
https://github.com/nascheme
Add unit tests for warnings.Contexthttps://github.com/python/cpython/pull/128300/commits/948a9e923723c2409114ca40dc096cc171399767
948a9e9https://github.com/python/cpython/pull/128300/commits/948a9e923723c2409114ca40dc096cc171399767
https://github.com/nascheme
Improve Context.resetwarnings().https://github.com/python/cpython/pull/128300/commits/fc20826cea9853888418e202c3ae1907260e9360
fc20826https://github.com/python/cpython/pull/128300/commits/fc20826cea9853888418e202c3ae1907260e9360
https://github.com/hawkinsp
hawkinsphttps://github.com/hawkinsp
Jan 9, 2025 https://github.com/python/cpython/pull/128300#ref-pullrequest-2773659285
BUG: move reduction initialization to ufunc initialization numpy/numpy#28123 https://github.com/numpy/numpy/pull/28123
https://github.com/nascheme
naschemehttps://github.com/nascheme
Feb 11, 2025https://github.com/python/cpython/pull/128300#issuecomment-2651685702
gh-130010https://github.com/python/cpython/pull/130010
Please reload this pagehttps://github.com/python/cpython/pull/128300
https://github.com/nascheme
naschemehttps://github.com/nascheme
Feb 11, 2025https://github.com/python/cpython/pull/128300#event-16269460631
https://github.com/gst
gsthttps://github.com/gst
Apr 7, 2025 https://github.com/python/cpython/pull/128300#pullrequestreview-2747397566
View reviewed changes https://github.com/python/cpython/pull/128300/files/fc20826cea9853888418e202c3ae1907260e9360
Lib/test/test_warnings/__init__.pyhttps://github.com/python/cpython/pull/128300/files/fc20826cea9853888418e202c3ae1907260e9360#diff-21be9e4809f5cd7dcd4665eb0054b4bf9d924c2c9ce0a010e85dba405e94d9e9
gsthttps://github.com/gst
Apr 7, 2025https://github.com/python/cpython/pull/128300#discussion_r2031584686
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/128300
naschemehttps://github.com/nascheme
Apr 7, 2025https://github.com/python/cpython/pull/128300#discussion_r2031941299
Please reload this pagehttps://github.com/python/cpython/pull/128300
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/128300
https://github.co/hiddenchars
https://github.com/python/cpython/pull/{{ revealButtonHref }}
Sign up for freehttps://github.com/join?source=comment-repo
Sign in to commenthttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F128300
https://github.com/1st1
1st1 https://github.com/1st1
https://github.com/erlend-aasland
erlend-aasland https://github.com/erlend-aasland
https://github.com/AA-Turner
AA-Turner https://github.com/AA-Turner
https://github.com/emmatyping
emmatyping https://github.com/emmatyping
https://github.com/itamaro
itamaro https://github.com/itamaro
https://github.com/corona10
corona10 https://github.com/corona10
https://github.com/gst
gst https://github.com/gst
https://github.com/python/cpython/pull/128300/files/fc20826cea9853888418e202c3ae1907260e9360
Please reload this pagehttps://github.com/python/cpython/pull/128300
https://github.com/nascheme
https://github.com/gst
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.