René's URL Explorer Experiment


Title: gh-58451: Add optional delete_on_close parameter to NamedTemporaryFile by Ev2geny · Pull Request #97015 · python/cpython · GitHub

Open Graph Title: gh-58451: Add optional delete_on_close parameter to NamedTemporaryFile by Ev2geny · Pull Request #97015 · python/cpython

X Title: gh-58451: Add optional delete_on_close parameter to NamedTemporaryFile by Ev2geny · Pull Request #97015 · python/cpython

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

Open Graph Description: This is a reincarnation of the already marked as awaiting merge PR 22431, which was subsequently closed due to some git mistake. This PR fixes issue 58451: tempfile.NamedTemporaryFile not particul...

X Description: This is a reincarnation of the already marked as awaiting merge PR 22431, which was subsequently closed due to some git mistake. This PR fixes issue 58451: tempfile.NamedTemporaryFile not particul...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:f1b03700-c8e8-2166-1a51-12c39e693528
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8BF0:C8AE2:B1EE2B:FAD948:6A4E85EF
html-safe-nonce1fd194d0a2a5368f0cc39c94f753d030eea67e812b18fe70524ce9a0798bacdd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkYwOkM4QUUyOkIxRUUyQjpGQUQ5NDg6NkE0RTg1RUYiLCJ2aXNpdG9yX2lkIjoiNTA0Mzk3MjE1OTI3MDk3OTA1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac7af7bcdf1b914ff01ceb36623be6e8c21479a5fef210bd0d548205474b47897c
hovercard-subject-tagpull_request:1064314862
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/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/97015/commits
twitter:imagehttps://opengraph.githubassets.com/2902d0df66df47739244a7af228b048b2dd2b638101c4c99a2e8fea766826be2/python/cpython/pull/97015
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/2902d0df66df47739244a7af228b048b2dd2b638101c4c99a2e8fea766826be2/python/cpython/pull/97015
og:image:altThis is a reincarnation of the already marked as awaiting merge PR 22431, which was subsequently closed due to some git mistake. This PR fixes issue 58451: tempfile.NamedTemporaryFile not particul...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameEv2geny
hostnamegithub.com
expected-hostnamegithub.com
None41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c
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
releasee6a744804e8e70f97b4d5a18a94dcc63db22f97a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/97015/commits#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F97015%2Fcommits
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%2F97015%2Fcommits
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%2Fcommits&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/97015/commits
Reloadhttps://github.com/python/cpython/pull/97015/commits
Reloadhttps://github.com/python/cpython/pull/97015/commits
Please reload this pagehttps://github.com/python/cpython/pull/97015/commits
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/97015/commits
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
zoobahttps://github.com/zooba
python:mainhttps://github.com/python/cpython/tree/main
Ev2geny:fix-issue-14243https://github.com/Ev2geny/cpython/tree/fix-issue-14243
Conversationhttps://github.com/python/cpython/pull/97015
Commits26 (26)https://github.com/python/cpython/pull/97015/commits
Checkshttps://github.com/python/cpython/pull/97015/checks
Files changedhttps://github.com/python/cpython/pull/97015/files
gh-58451: Add optional delete_on_close parameter to NamedTemporaryFilehttps://github.com/python/cpython/pull/97015/commits#top
zoobahttps://github.com/zooba
python:mainhttps://github.com/python/cpython/tree/main
Ev2geny:fix-issue-14243https://github.com/Ev2geny/cpython/tree/fix-issue-14243
Brought the same changes as in now closed PR 22431, but to the latest version of mainhttps://github.com/python/cpython/pull/97015/commits/3df957c5d7c85abefb905886ef600fdcc4d7ef00
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
3df957chttps://github.com/python/cpython/pull/97015/commits/3df957c5d7c85abefb905886ef600fdcc4d7ef00
https://github.com/python/cpython/tree/3df957c5d7c85abefb905886ef600fdcc4d7ef00
Based on the review from @eryksun the code and the documentation is updated to handle the situation, when delete = True, delete_on_close = Flase and no context manager was usedhttps://github.com/python/cpython/pull/97015/commits/c4cf39f916abd84779e5f59363759308299ed09e
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
c4cf39fhttps://github.com/python/cpython/pull/97015/commits/c4cf39f916abd84779e5f59363759308299ed09e
https://github.com/python/cpython/tree/c4cf39f916abd84779e5f59363759308299ed09e
documentation is slightly correctedhttps://github.com/python/cpython/pull/97015/commits/ac0b241572cae7527a5c4fdc19e9a8f16287aad2
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
ac0b241https://github.com/python/cpython/pull/97015/commits/ac0b241572cae7527a5c4fdc19e9a8f16287aad2
https://github.com/python/cpython/tree/ac0b241572cae7527a5c4fdc19e9a8f16287aad2
minor documentation updatehttps://github.com/python/cpython/pull/97015/commits/384614fd09f9dedaf995a35b348710b755916505
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
384614fhttps://github.com/python/cpython/pull/97015/commits/384614fd09f9dedaf995a35b348710b755916505
https://github.com/python/cpython/tree/384614fd09f9dedaf995a35b348710b755916505
Update Doc/whatsnew/3.12.rsthttps://github.com/python/cpython/pull/97015/commits/0e0b6ba04d62ae6be33abbbc3ed042584908bd4c
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
merwokhttps://github.com/python/cpython/commits?author=merwok
0e0b6bahttps://github.com/python/cpython/pull/97015/commits/0e0b6ba04d62ae6be33abbbc3ed042584908bd4c
https://github.com/python/cpython/tree/0e0b6ba04d62ae6be33abbbc3ed042584908bd4c
Deletion of file upon finalization is moved from _TemporaryFileWrapper to _TemporaryFileCloserhttps://github.com/python/cpython/pull/97015/commits/cc81ab5478d9cc17620a17906c0612bee74339b8
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
cc81ab5https://github.com/python/cpython/pull/97015/commits/cc81ab5478d9cc17620a17906c0612bee74339b8
https://github.com/python/cpython/tree/cc81ab5478d9cc17620a17906c0612bee74339b8
Some additions to Lib/test/test_tempfile.pyhttps://github.com/python/cpython/pull/97015/commits/5af6150aef9911bd4fe2a03b19e25f60ad794f5c
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
5af6150https://github.com/python/cpython/pull/97015/commits/5af6150aef9911bd4fe2a03b19e25f60ad794f5c
https://github.com/python/cpython/tree/5af6150aef9911bd4fe2a03b19e25f60ad794f5c
clearing of the files in the situation when delete and not delete_on_close is moved to _TemporaryFileWrapperhttps://github.com/python/cpython/pull/97015/commits/239354e2e4a09914cd9fac0847e9d883c84c0e08
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
239354ehttps://github.com/python/cpython/pull/97015/commits/239354e2e4a09914cd9fac0847e9d883c84c0e08
https://github.com/python/cpython/tree/239354e2e4a09914cd9fac0847e9d883c84c0e08
if statement is added to avoid errors, when testing. Not sure 100% is this is a solution or workaroundhttps://github.com/python/cpython/pull/97015/commits/5de68c0556058c762572e8afe4c2981b38987a1b
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
5de68c0https://github.com/python/cpython/pull/97015/commits/5de68c0556058c762572e8afe4c2981b38987a1b
https://github.com/python/cpython/tree/5de68c0556058c762572e8afe4c2981b38987a1b
Apply suggestions from code reviewhttps://github.com/python/cpython/pull/97015/commits/eef343984e5d422fd3994fb233a696f313d89927
eef3439https://github.com/python/cpython/pull/97015/commits/eef343984e5d422fd3994fb233a696f313d89927
https://github.com/python/cpython/tree/eef343984e5d422fd3994fb233a696f313d89927
__del__ was defined twice in _TemporaryFileWrapper. Fixed nowhttps://github.com/python/cpython/pull/97015/commits/c9801eec27f494cd5da99e7604e688adb21fa0be
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
c9801eehttps://github.com/python/cpython/pull/97015/commits/c9801eec27f494cd5da99e7604e688adb21fa0be
https://github.com/python/cpython/tree/c9801eec27f494cd5da99e7604e688adb21fa0be
_TemporaryFileCloser is returned to original state and the logic, which takes into account delete_on_close moved to _TemporaryFileWrapper (suggestion of @ekisun)https://github.com/python/cpython/pull/97015/commits/6944ab23e513861508fe643558efce47f178875e
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
6944ab2https://github.com/python/cpython/pull/97015/commits/6944ab23e513861508fe643558efce47f178875e
https://github.com/python/cpython/tree/6944ab23e513861508fe643558efce47f178875e
All delete operations are moved to the class _TemporaryFileCloserhttps://github.com/python/cpython/pull/97015/commits/44f0664b3e28e5e0d40ff64238544258b27206ff
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
44f0664https://github.com/python/cpython/pull/97015/commits/44f0664b3e28e5e0d40ff64238544258b27206ff
https://github.com/python/cpython/tree/44f0664b3e28e5e0d40ff64238544258b27206ff
Minor update to commentshttps://github.com/python/cpython/pull/97015/commits/1dfaf72a90f41039ef7786eeac342993f61259da
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
1dfaf72https://github.com/python/cpython/pull/97015/commits/1dfaf72a90f41039ef7786eeac342993f61259da
https://github.com/python/cpython/tree/1dfaf72a90f41039ef7786eeac342993f61259da
Whitespec fixes by patchcheck.pyhttps://github.com/python/cpython/pull/97015/commits/e54feb5d8621f79ff8437d3209b80b997aa9d199
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
e54feb5https://github.com/python/cpython/pull/97015/commits/e54feb5d8621f79ff8437d3209b80b997aa9d199
https://github.com/python/cpython/tree/e54feb5d8621f79ff8437d3209b80b997aa9d199
Update Lib/tempfile.pyhttps://github.com/python/cpython/pull/97015/commits/d2d11194ba0648d6b83b0982cca418911fb2d3ac
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
eryksunhttps://github.com/python/cpython/commits?author=eryksun
d2d1119https://github.com/python/cpython/pull/97015/commits/d2d11194ba0648d6b83b0982cca418911fb2d3ac
https://github.com/python/cpython/tree/d2d11194ba0648d6b83b0982cca418911fb2d3ac
Update Lib/tempfile.pyhttps://github.com/python/cpython/pull/97015/commits/bd4b2ddc10476bc0c817431da34bac1af1f37da5
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
eryksunhttps://github.com/python/cpython/commits?author=eryksun
bd4b2ddhttps://github.com/python/cpython/pull/97015/commits/bd4b2ddc10476bc0c817431da34bac1af1f37da5
https://github.com/python/cpython/tree/bd4b2ddc10476bc0c817431da34bac1af1f37da5
Modified exception handling in NamedTemporaryFilehttps://github.com/python/cpython/pull/97015/commits/29eeaff60ec551fbdd96ea04a202597906334a01
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
29eeaffhttps://github.com/python/cpython/pull/97015/commits/29eeaff60ec551fbdd96ea04a202597906334a01
https://github.com/python/cpython/tree/29eeaff60ec551fbdd96ea04a202597906334a01
Wrapping at 80 characters is fixedhttps://github.com/python/cpython/pull/97015/commits/5306b6dd52a7813cf8c93d49387106fcae2dadce
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
5306b6dhttps://github.com/python/cpython/pull/97015/commits/5306b6dd52a7813cf8c93d49387106fcae2dadce
https://github.com/python/cpython/tree/5306b6dd52a7813cf8c93d49387106fcae2dadce
Update Lib/tempfile.pyhttps://github.com/python/cpython/pull/97015/commits/1c99fb344efe837c139376bb802eeabf971ac7a9
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
eryksunhttps://github.com/python/cpython/commits?author=eryksun
1c99fb3https://github.com/python/cpython/pull/97015/commits/1c99fb344efe837c139376bb802eeabf971ac7a9
https://github.com/python/cpython/tree/1c99fb344efe837c139376bb802eeabf971ac7a9
Documentation update, based on the feedback from @zoobahttps://github.com/python/cpython/pull/97015/commits/29b89d3d543e898361af93058b8548f5717682e1
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
29b89d3https://github.com/python/cpython/pull/97015/commits/29b89d3d543e898361af93058b8548f5717682e1
https://github.com/python/cpython/tree/29b89d3d543e898361af93058b8548f5717682e1
Minor PEP8 update based on the feedback from @zoobahttps://github.com/python/cpython/pull/97015/commits/e58602812bc23388c2eff31234223706cd49693d
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
e586028https://github.com/python/cpython/pull/97015/commits/e58602812bc23388c2eff31234223706cd49693d
https://github.com/python/cpython/tree/e58602812bc23388c2eff31234223706cd49693d
Improving comments in the init test file, based on the feedback from @eryksunhttps://github.com/python/cpython/pull/97015/commits/3eceb4549bc0529eddcacec4e0e54bc175d6f28f
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
eryksunhttps://github.com/python/cpython/commits?author=eryksun
3eceb45https://github.com/python/cpython/pull/97015/commits/3eceb4549bc0529eddcacec4e0e54bc175d6f28f
https://github.com/python/cpython/tree/3eceb4549bc0529eddcacec4e0e54bc175d6f28f
Updating of documentationhttps://github.com/python/cpython/pull/97015/commits/892e87d5f0d9d082a796a0855519624c4f2e8bb4
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
892e87dhttps://github.com/python/cpython/pull/97015/commits/892e87d5f0d9d082a796a0855519624c4f2e8bb4
https://github.com/python/cpython/tree/892e87d5f0d9d082a796a0855519624c4f2e8bb4
Merge branch 'fix-issue-14243' of https://github.com/Ev2geny/cpython into fix-issue-14243https://github.com/python/cpython/pull/97015/commits/67996b281bf652a08ae1f1ab07b507fd9627f0f8
https://github.com/Ev2geny
Ev2genyhttps://github.com/python/cpython/commits?author=Ev2geny
67996b2https://github.com/python/cpython/pull/97015/commits/67996b281bf652a08ae1f1ab07b507fd9627f0f8
https://github.com/python/cpython/tree/67996b281bf652a08ae1f1ab07b507fd9627f0f8
Apply suggestions from code reviewhttps://github.com/python/cpython/pull/97015/commits/07b963e453a9d15086a819804803b982d7cd94aa
https://github.com/zooba
zoobahttps://github.com/python/cpython/commits?author=zooba
07b963ehttps://github.com/python/cpython/pull/97015/commits/07b963e453a9d15086a819804803b982d7cd94aa
https://github.com/python/cpython/tree/07b963e453a9d15086a819804803b982d7cd94aa
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.