René's URL Explorer Experiment


Title: fix(util): tolerate deleted temporary environment variables by Abedyn · Pull Request #2340 · gitpython-developers/GitPython · GitHub

Open Graph Title: fix(util): tolerate deleted temporary environment variables by Abedyn · Pull Request #2340 · gitpython-developers/GitPython

X Title: fix(util): tolerate deleted temporary environment variables by Abedyn · Pull Request #2340 · gitpython-developers/GitPython

Description: patch_env() raises KeyError on exit if its variable was originally absent and the context body deletes it. If the body also raises an exception, the cleanup error masks that exception. Use os.environ.pop(name, None) when restoring an originally absent variable. Add 18 regression cases covering absent, empty and populated original values; unchanged, replaced and deleted temporary values; and normal and exceptional exits. Motivation: this was discovered while inspecting GitPython with a user seeking their first small Python contribution to Git tooling on Windows. The goal is to make the environment helper's restoration behavior consistent when a caller changes the temporary variable. Codex prepared the implementation, tests and this description. Validation on Windows, Python 3.13.17 and Git 2.56.0.windows.4: Before the fix: 2 failed, 16 passed. After the fix: 18 passed with GIT_PYTHON_BACKEND=cli and python -m pytest --noconftest -o addopts='' test/test_patch_env.py -q --tb=short. Ruff lint and formatting checks passed for both changed files; git diff --check passed. The full suite and its conftest hooks were not run. Installing the test extra with binary-only GixPython failed because no compatible Windows wheel for GixPython 0.3.0 was available. The focused tests do not use repository fixtures or Gix.

Open Graph Description: patch_env() raises KeyError on exit if its variable was originally absent and the context body deletes it. If the body also raises an exception, the cleanup error masks that exception. Use os.envir...

X Description: patch_env() raises KeyError on exit if its variable was originally absent and the context body deletes it. If the body also raises an exception, the cleanup error masks that exception. Use os.envir...

Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/2340

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:626b71ef-5a02-6ed5-74b2-b41b3a127712
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8C98:28815B:1CDE4F:274832:6B00BF4E
html-safe-noncea694db2199e1858867226cec3e9cf74f8484f0feaba2c1373f9f3ae4981329b2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Qzk4OjI4ODE1QjoxQ0RFNEY6Mjc0ODMyOjZCMDBCRjRFIiwidmlzaXRvcl9pZCI6IjM0NzAwNTQ3MjA4OTM1ODE1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4f5d4f901b341ee17f73f165582816e42a08bd65046ed1279beca92ea8315185
hovercard-subject-tagpull_request:5157566969
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/gitpython-developers/GitPython/pull/2340/files
twitter:imagehttps://avatars.githubusercontent.com/u/168976722?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/168976722?s=400&v=4
og:image:altpatch_env() raises KeyError on exit if its variable was originally absent and the context body deletes it. If the body also raises an exception, the cleanup error masks that exception. Use os.envir...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126087
octolytics-dimension-repository_nwogitpython-developers/GitPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126087
octolytics-dimension-repository_network_root_nwogitpython-developers/GitPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1fee81a280ea86312b69448e261b418189bfd5b5
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/pull/2340/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fpull%2F2340%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fpull%2F2340%2Ffiles
Sign uphttps://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=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/pull/2340/files
Reloadhttps://github.com/gitpython-developers/GitPython/pull/2340/files
Reloadhttps://github.com/gitpython-developers/GitPython/pull/2340/files
gitpython-developershttps://github.com/gitpython-developers
GitPythonhttps://github.com/gitpython-developers/GitPython
Codehttps://github.com/gitpython-developers/GitPython
Issues1 (1)https://github.com/gitpython-developers/GitPython/issues
Pull requestshttps://github.com/gitpython-developers/GitPython/pulls
Discussionshttps://github.com/gitpython-developers/GitPython/discussions
Actionshttps://github.com/gitpython-developers/GitPython/actions
Security and quality42 (42)https://github.com/gitpython-developers/GitPython/security
Insightshttps://github.com/gitpython-developers/GitPython/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fgitpython-developers%2FGitPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgitpython-developers%2FGitPython%2Fissues%2Fnew%2Fchoose
Byronhttps://github.com/Byron
gitpython-developers:mainhttps://github.com/gitpython-developers/GitPython/tree/main
Abedyn:fix/patch-env-deleted-variablehttps://github.com/Abedyn/GitPython/tree/fix/patch-env-deleted-variable
Conversation 1 https://github.com/gitpython-developers/GitPython/pull/2340
Commits 2 https://github.com/gitpython-developers/GitPython/pull/2340/commits
Checks 64 https://github.com/gitpython-developers/GitPython/pull/2340/checks
Files changed https://github.com/gitpython-developers/GitPython/pull/2340/files
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/2340/files
fix(util): tolerate deleted temporary environment variables https://github.com/gitpython-developers/GitPython/pull/2340/files#top
Show all changes 2 commits https://github.com/gitpython-developers/GitPython/pull/2340/files
e52b7f8 fix(util): tolerate deleted temporary environment variables Abedyn Nov 4, 2026 https://github.com/gitpython-developers/GitPython/pull/2340/commits/e52b7f8ed03196aa911f37128b36b0d89e9927e1
32b4d8e review Byron Nov 5, 2026 https://github.com/gitpython-developers/GitPython/pull/2340/commits/32b4d8e7005eee2b5e927adf5dc9151e8b34001a
Clear filters https://github.com/gitpython-developers/GitPython/pull/2340/files
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/2340/files
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/2340/files
git/util.pyhttps://github.com/gitpython-developers/GitPython/pull/2340/files#diff-cb13395ac36dd593e722ec548880a091f39732af5c934880144d1a95de67944e
View file https://github.com/Abedyn/GitPython/blob/32b4d8e7005eee2b5e927adf5dc9151e8b34001a/git/util.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/gitpython-developers/GitPython/pull/2340/{{ revealButtonHref }}
https://github.com/gitpython-developers/GitPython/pull/2340/files#diff-cb13395ac36dd593e722ec548880a091f39732af5c934880144d1a95de67944e
https://github.com/gitpython-developers/GitPython/pull/2340/files#diff-cb13395ac36dd593e722ec548880a091f39732af5c934880144d1a95de67944e
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/2340/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.