René's URL Explorer Experiment


Title: gh-128670: keep the public base executable when creating a venv from a venv by gaborbernat · Pull Request #150999 · python/cpython · GitHub

Open Graph Title: gh-128670: keep the public base executable when creating a venv from a venv by gaborbernat · Pull Request #150999 · python/cpython

X Title: gh-128670: keep the public base executable when creating a venv from a venv by gaborbernat · Pull Request #150999 · python/cpython

Description: Problem When a virtual environment is created from inside another virtual environment, and the base interpreter is reached through a stable public symlink, the child environment records the internal, version-stamped target in its pyvenv.cfg home instead of the stable public path. This happens with the common ways people now get Python: Homebrew — the stable …/opt/python@3.x/bin path resolves to a versioned …/Cellar/python@3.x/3.x.y/… path; relocatable / uv-managed interpreters and NFS canonical paths. When that internal path later changes — a Homebrew patch upgrade deletes the old Cellar/3.x.y tree, an NFS mount moves — the recorded home dangles and the environment breaks. The public symlink exists precisely so callers don't depend on the internal path, so baking it in defeats the purpose. Reproduction (Linux; also reproduces on Homebrew 3.12–3.14): $ mkdir -p /pub/bin && ln -s /usr/local/bin/python3.x /pub/bin/ $ /pub/bin/python3.x -m venv /v1 $ /v1/bin/python -m venv /v2 $ grep home /v1/pyvenv.cfg # home = /pub/bin (public, kept) $ grep home /v2/pyvenv.cfg # home = /usr/local/bin (internal — bled through) Solution In getpath's pyvenv.cfg home branch, when computing base_executable, prefer the executable as named in home (the public location the venv was created from) when it resolves to the same real file as the running interpreter, instead of fully resolving the symlink. Fall back to the previous fully-resolved path when home has no matching executable or it points elsewhere. The candidate is looked up by the resolved interpreter's name, since a venv's primary executable is python while home may only provide python3.x. This is the getpath-feasible form of what uv settled on (astral-sh/uv#8433) and corrects #128913, which matched on python and so missed the common python3.x-only case. Why it's safe Exactly one behaviour changes: a venv-from-venv whose base is reached via a public symlink now records the public path. Non-symlinked bases, a home with no matching executable, and a home pointing at a different file all produce the identical result as before. Guarded: the public path is kept only if it exists and resolves to the same real file as the running interpreter, so base_executable is never pointed at a missing or different binary. Stdlib resolution is untouched: base_prefix and the standard-library search run afterward as before and still resolve to the real location — the created environments run with the correct base_prefix (verified end-to-end). Validated: four new test_getpath cases (public symlink, versioned-name, mismatch-guard, no-home-exe fallback) plus test_getpath/test_venv and a broader sweep (test_embed, test_site, test_sysconfig, test_subprocess) — 654 tests, no regressions; and end-to-end on Linux across single-hop, multi-hop, and a 3-level venv chain. Issue: gh-128670

Open Graph Description: Problem When a virtual environment is created from inside another virtual environment, and the base interpreter is reached through a stable public symlink, the child environment records the interna...

X Description: Problem When a virtual environment is created from inside another virtual environment, and the base interpreter is reached through a stable public symlink, the child environment records the interna...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:b315c97b-bbfa-c6ad-2f2c-0e8c1c2f7f51
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8BDA:633B1:36FCD68:4BE5EB9:6A4F3615
html-safe-nonce8ef674a490ef24be029e5da6d557fcf6dbc0f66edcd68b79dba2d3192fbc32c7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkRBOjYzM0IxOjM2RkNENjg6NEJFNUVCOTo2QTRGMzYxNSIsInZpc2l0b3JfaWQiOiIxNzc1NjE0ODExMzgxMzgwNjI5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaca23f471dce1b71726e590b104d61e8e5963448be83f9eb76e49f48f7c6189b7a
hovercard-subject-tagpull_request:3814007507
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/150999/files
twitter:imagehttps://avatars.githubusercontent.com/u/690238?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/690238?s=400&v=4
og:image:altProblem When a virtual environment is created from inside another virtual environment, and the base interpreter is reached through a stable public symlink, the child environment records the interna...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9
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
release2b8f23afb982271f1b22258a94aede67a6b77760
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/150999/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F150999%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%2F150999%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/150999/files
Reloadhttps://github.com/python/cpython/pull/150999/files
Reloadhttps://github.com/python/cpython/pull/150999/files
Please reload this pagehttps://github.com/python/cpython/pull/150999/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/150999/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.6k 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
gaborbernathttps://github.com/gaborbernat
python:mainhttps://github.com/python/cpython/tree/main
gaborbernat:gh-128670-base-executable-symlinkhttps://github.com/gaborbernat/cpython/tree/gh-128670-base-executable-symlink
Conversation 0 https://github.com/python/cpython/pull/150999
Commits 1 https://github.com/python/cpython/pull/150999/commits
Checks 50 https://github.com/python/cpython/pull/150999/checks
Files changed https://github.com/python/cpython/pull/150999/files
Please reload this pagehttps://github.com/python/cpython/pull/150999/files
gh-128670: keep the public base executable when creating a venv from a venv https://github.com/python/cpython/pull/150999/files#top
Show all changes 1 commit https://github.com/python/cpython/pull/150999/files
b9f7703 gh-128670: keep the public base executable for venv-from-venv gaborbernat Jun 6, 2026 https://github.com/python/cpython/pull/150999/commits/b9f7703bddb540f996272a3843e75fa03ea2741f
Clear filters https://github.com/python/cpython/pull/150999/files
Please reload this pagehttps://github.com/python/cpython/pull/150999/files
Please reload this pagehttps://github.com/python/cpython/pull/150999/files
test_getpath.py https://github.com/python/cpython/pull/150999/files#diff-a4b5c72cb492c25566a62a6df189db86af116f3e2ca11021d999344b9a618391
2026-06-05-18-39-35.gh-issue-128670.75Gm5f.rst https://github.com/python/cpython/pull/150999/files#diff-1e6adfe06b367a42bff99d57319836c04a320001ae14f4dd6f427831550c5cb7
getpath.py https://github.com/python/cpython/pull/150999/files#diff-6fce05f0b43cd31ded3d7c0b3db040a75a61c79874dd660485f040a1773e3418
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L254
Lib/test/test_getpath.pyhttps://github.com/python/cpython/pull/150999/files#diff-a4b5c72cb492c25566a62a6df189db86af116f3e2ca11021d999344b9a618391
View file https://github.com/python/cpython/blob/b9f7703bddb540f996272a3843e75fa03ea2741f/Lib/test/test_getpath.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150999/{{ revealButtonHref }}
https://github.com/python/cpython/pull/150999/files#diff-a4b5c72cb492c25566a62a6df189db86af116f3e2ca11021d999344b9a618391
https://github.com/python/cpython/pull/150999/files#diff-a4b5c72cb492c25566a62a6df189db86af116f3e2ca11021d999344b9a618391
Misc/NEWS.d/next/Library/2026-06-05-18-39-35.gh-issue-128670.75Gm5f.rsthttps://github.com/python/cpython/pull/150999/files#diff-1e6adfe06b367a42bff99d57319836c04a320001ae14f4dd6f427831550c5cb7
View file https://github.com/python/cpython/blob/b9f7703bddb540f996272a3843e75fa03ea2741f/Misc/NEWS.d/next/Library/2026-06-05-18-39-35.gh-issue-128670.75Gm5f.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150999/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L255
Modules/getpath.pyhttps://github.com/python/cpython/pull/150999/files#diff-6fce05f0b43cd31ded3d7c0b3db040a75a61c79874dd660485f040a1773e3418
View file https://github.com/python/cpython/blob/b9f7703bddb540f996272a3843e75fa03ea2741f/Modules/getpath.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150999/{{ revealButtonHref }}
https://github.com/python/cpython/pull/150999/files#diff-6fce05f0b43cd31ded3d7c0b3db040a75a61c79874dd660485f040a1773e3418
https://github.com/python/cpython/pull/150999/files#diff-6fce05f0b43cd31ded3d7c0b3db040a75a61c79874dd660485f040a1773e3418
Please reload this pagehttps://github.com/python/cpython/pull/150999/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.