René's URL Explorer Experiment


Title: gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.addsitedir() by warsaw · Pull Request #149659 · python/cpython · GitHub

Open Graph Title: gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.addsitedir() by warsaw · Pull Request #149659 · python/cpython

X Title: gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.addsitedir() by warsaw · Pull Request #149659 · python/cpython

Description: Fix site.addsitedir() to allow re-entrant calls from within startup files. Previously, a .pth file containing an import line that called site.addsitedir() (or a .start entry point doing the same) could crash with RuntimeError: dictionary changed size during iteration during site initialization, breaking tools such as uv run --with. mkdir -p /tmp/site-repro/root /tmp/site-repro/overlay printf 'import site; site.addsitedir("/tmp/site-repro/overlay")\n' > /tmp/site-repro/root/reenter.pth ./python.exe -S -c 'import site; site.addsitedir("/tmp/site-repro/root"); print("done")' prints "done" for me. uv run --python /Users/jelle/py/cpython/python.exe --with iniconfig python -c 'import iniconfig' does not crash. The implementation is more comprehensive than #149516 and is more inline with a suggestion @ncoghlan made on the original PR. Thanks @zsol for providing your PR. @JelleZijlstra please take a look. Issue: gh-149504

Open Graph Description: Fix site.addsitedir() to allow re-entrant calls from within startup files. Previously, a .pth file containing an import line that called site.addsitedir() (or a .start entry point doing the same) ...

X Description: Fix site.addsitedir() to allow re-entrant calls from within startup files. Previously, a .pth file containing an import line that called site.addsitedir() (or a .start entry point doing the same) ...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:9339f8a1-fd0a-abee-9e06-36342e5f24e8
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD05C:35E4DB:8A2310:C40E98:6A56594B
html-safe-nonce398c2051fc099baf7e845619fa290fc4a7bfee9a464c751121e929865251d91d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDVDOjM1RTREQjo4QTIzMTA6QzQwRTk4OjZBNTY1OTRCIiwidmlzaXRvcl9pZCI6IjM0NTUzMjI2NjYyNTI1MjM4NTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac86d6aadc921e93458a5cce7a729f79e987225b320b355cf6795faeb11bb6de8c
hovercard-subject-tagpull_request:3659873785
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///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/149659/files
twitter:imagehttps://avatars.githubusercontent.com/u/210184?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/210184?s=400&v=4
og:image:altFix site.addsitedir() to allow re-entrant calls from within startup files. Previously, a .pth file containing an import line that called site.addsitedir() (or a .start entry point doing the same) ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecffc1b7eb44a3dbb1e61c2a0523cad1f04e0368d730bf85ac498c992baf19e7d
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release233d2274d9c68198aa6cb23d1db680b5c0b58bba
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/149659/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F149659%2Ffiles
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%2F149659%2Ffiles
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%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/149659/files
Reloadhttps://github.com/python/cpython/pull/149659/files
Reloadhttps://github.com/python/cpython/pull/149659/files
Please reload this pagehttps://github.com/python/cpython/pull/149659/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/149659/files
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
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
warsawhttps://github.com/warsaw
python:mainhttps://github.com/python/cpython/tree/main
warsaw:gh-149504https://github.com/warsaw/cpython/tree/gh-149504
Conversation 6 https://github.com/python/cpython/pull/149659
Commits 9 https://github.com/python/cpython/pull/149659/commits
Checks 56 https://github.com/python/cpython/pull/149659/checks
Files changed https://github.com/python/cpython/pull/149659/files
Please reload this pagehttps://github.com/python/cpython/pull/149659/files
gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.addsitedir() https://github.com/python/cpython/pull/149659/files#top
Show all changes 9 commits https://github.com/python/cpython/pull/149659/files
7108fb7 Add re-entrant tests for gh-149504 warsaw May 11, 2026 https://github.com/python/cpython/pull/149659/commits/7108fb7024a7cc4ba785401b8cdfc9aab8999dde
aae5378 Add end-to-end integration test coverage warsaw May 11, 2026 https://github.com/python/cpython/pull/149659/commits/aae5378fc3095f127b69a623e761ae7b2b848326
dc96d5d Implement a state class to process .pth and .start files warsaw May 11, 2026 https://github.com/python/cpython/pull/149659/commits/dc96d5d726a9864eb871feb5a4b2a4989153722b
c6cfcb0 Add a blurb warsaw May 11, 2026 https://github.com/python/cpython/pull/149659/commits/c6cfcb03f80b563fdb40040b87c39eedafcf2b14
04b67f7 One small round of cleanup. warsaw May 11, 2026 https://github.com/python/cpython/pull/149659/commits/04b67f7d8e9752f11781c67f78cd766693d393f2
c38ec2b Merge branch 'main' into gh-149504 warsaw May 11, 2026 https://github.com/python/cpython/pull/149659/commits/c38ec2b268b1228acb3a706f6d3d057fbf258347
ea34446 Merge branch 'main' into gh-149504 warsaw May 11, 2026 https://github.com/python/cpython/pull/149659/commits/ea344462b0a5687f18d9bc83e9dc46d14211a4d1
558ece4 Merge branch 'main' into gh-149504 warsaw May 12, 2026 https://github.com/python/cpython/pull/149659/commits/558ece4be223242a69a397fda8a636e225624f3a
9c488d7 Merge branch 'main' into gh-149504 warsaw May 13, 2026 https://github.com/python/cpython/pull/149659/commits/9c488d71ccb4a0cd18a5043040a59f4ffb63fea3
Clear filters https://github.com/python/cpython/pull/149659/files
Please reload this pagehttps://github.com/python/cpython/pull/149659/files
Please reload this pagehttps://github.com/python/cpython/pull/149659/files
site.py https://github.com/python/cpython/pull/149659/files#diff-0783c435d23e776f5f679cb9c63f2ad98ad13047204562ed2408bd85aa17fd33
test_site.py https://github.com/python/cpython/pull/149659/files#diff-fc5d47b8004cede89f7a0cbc1235363226f8167e2e40055a9e04c572afcb98da
2026-05-10-23-51-23.gh-issue-149504.pDSCbn.rst https://github.com/python/cpython/pull/149659/files#diff-4dcdf1ff445b0e3b4d54e9e5c7c07aade0db01614de79cdffadf3331a6fc5591
Please reload this pagehttps://github.com/python/cpython/pull/149659/files
Please reload this pagehttps://github.com/python/cpython/pull/149659/files
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.