René's URL Explorer Experiment


Title: gh-140601: Add ResourceWarning to iterparse when not closed by osamakader · Pull Request #140603 · python/cpython · GitHub

Open Graph Title: gh-140601: Add ResourceWarning to iterparse when not closed by osamakader · Pull Request #140603 · python/cpython

X Title: gh-140601: Add ResourceWarning to iterparse when not closed by osamakader · Pull Request #140603 · python/cpython

Description: When iterparse() opens a file by filename and is not explicitly closed, emit a ResourceWarning to alert developers of the resource leak. This implements the TODO comment at line 1270 of ElementTree.py which has been requesting this feature since the close() method was added. Add _closed flag to IterParseIterator to track state Emit ResourceWarning in del if not closed Add comprehensive test cases Update existing tests to properly close iterators Issue: gh-140601

Open Graph Description: When iterparse() opens a file by filename and is not explicitly closed, emit a ResourceWarning to alert developers of the resource leak. This implements the TODO comment at line 1270 of ElementTree...

X Description: When iterparse() opens a file by filename and is not explicitly closed, emit a ResourceWarning to alert developers of the resource leak. This implements the TODO comment at line 1270 of ElementTree...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:7f64a50f-0576-fa8a-b544-dfab233c5288
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE5AC:384EC7:AE8F4D:E8D1AF:69963B59
html-safe-nonce71ac4c5df7bda613d2f3bbd17af0932034d01917fc859013a48ea6043aa9816b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNUFDOjM4NEVDNzpBRThGNEQ6RThEMUFGOjY5OTYzQjU5IiwidmlzaXRvcl9pZCI6IjIwODk0MjU1Nzg5NDQyNDg2NjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacbabd6b1997fc6d8a4e965ba09383f7bba86501bfe3243afe7542996dfe5ac1cc
hovercard-subject-tagpull_request:2947689996
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/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
twitter:imagehttps://avatars.githubusercontent.com/u/78818069?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/78818069?s=400&v=4
og:image:altWhen iterparse() opens a file by filename and is not explicitly closed, emit a ResourceWarning to alert developers of the resource leak. This implements the TODO comment at line 1270 of ElementTree...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonebb5fc598983958d677e5179b50e71c2bfa2a8ac1568110d429775cd645bbe799
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseddb60c6732f32ef004e33aed240bef867c5f545f
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F140603%2Fcommits%2F0f9b5094c712f8ca8093017140f1af78a191b965
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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/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%2F140603%2Fcommits%2F0f9b5094c712f8ca8093017140f1af78a191b965
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/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
Reloadhttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
Reloadhttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.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.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security 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 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
serhiy-storchakahttps://github.com/serhiy-storchaka
python:mainhttps://github.com/python/cpython/tree/main
osamakader:issue-140601-iterparse-warninghttps://github.com/osamakader/cpython/tree/issue-140601-iterparse-warning
Conversation 33 https://github.com/python/cpython/pull/140603
Commits 17 https://github.com/python/cpython/pull/140603/commits
Checks 44 https://github.com/python/cpython/pull/140603/checks
Files changed https://github.com/python/cpython/pull/140603/files
Please reload this pagehttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
gh-140601: Add ResourceWarning to iterparse when not closed https://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965#top
Show all changes 17 commits https://github.com/python/cpython/pull/140603/files
bf3f888 gh-140601: Add ResourceWarning to iterparse when not closed osamakader Oct 25, 2025 https://github.com/python/cpython/pull/140603/commits/bf3f8888b277817bb674b899c564cef27cfd0a12
e6c11de Address review feedback from serhiy-storchaka osamakader Oct 26, 2025 https://github.com/python/cpython/pull/140603/commits/e6c11de1ba59c128c2711374cd53f8eba3891c12
53f63b9 remove extra whitespace osamakader Oct 26, 2025 https://github.com/python/cpython/pull/140603/commits/53f63b9971332ce075bfd7037d0fe51dd54eb8c3
c8ea776 remove unused import osamakader Oct 26, 2025 https://github.com/python/cpython/pull/140603/commits/c8ea7768a3e062132e8bd497559940ab27652c70
fcd7ca0 Use % formatting instead of f-strings in __del__ osamakader Oct 26, 2025 https://github.com/python/cpython/pull/140603/commits/fcd7ca09a77f22aa6362bce805746c4254d0a5ec
0f9b509 Add assertions to verify ResourceWarning content osamakader Oct 26, 2025 https://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
6e3b071 Remove redundant test_iterparse_resource_warning function osamakader Oct 26, 2025 https://github.com/python/cpython/pull/140603/commits/6e3b0711626669da8e458d09f1bd3fe9bef2876b
86fc36b Remove source=self from ResourceWarning osamakader Oct 26, 2025 https://github.com/python/cpython/pull/140603/commits/86fc36b3d3e9d4d5ea670e2b50a99b55332e889d
329c09c Add explicit close(). serhiy-storchaka Oct 27, 2025 https://github.com/python/cpython/pull/140603/commits/329c09c4054e8257b1573b2b4c2484e1f700a3f5
dd20441 Reorganize tests. serhiy-storchaka Oct 27, 2025 https://github.com/python/cpython/pull/140603/commits/dd204415282d99ec7bbf51528e2c8a3a7e7bd997
b1f67a4 Exhausted or failed iterators are auto-closed. serhiy-storchaka Oct 27, 2025 https://github.com/python/cpython/pull/140603/commits/b1f67a4eb6506dcdc5eab06e00eee07aca61335c
15c0c5b Add versionchanged directive for ResourceWarning osamakader Oct 27, 2025 https://github.com/python/cpython/pull/140603/commits/15c0c5b99dd5bd0308b7da3cb35b9da8ff9b04f2
a7ef9f2 Merge branch 'main' into issue-140601-iterparse-warning serhiy-storchaka Nov 12, 2025 https://github.com/python/cpython/pull/140603/commits/a7ef9f28693e2be4d0e3f290dbfcb5af0790daf8
766d510 Always emit a warning. Add tests for exhausted not closed iterator. serhiy-storchaka Nov 12, 2025 https://github.com/python/cpython/pull/140603/commits/766d5103bae24ef3afdc7945120faa7ef6a131dc
53880a6 Apply suggestions from code review serhiy-storchaka Nov 13, 2025 https://github.com/python/cpython/pull/140603/commits/53880a65a4963bffd9ce3a1d6a45dfd74f45091c
8a37683 Refactor tests. serhiy-storchaka Nov 13, 2025 https://github.com/python/cpython/pull/140603/commits/8a37683925f56a0ad890076325427bc323832d7b
6c5c5e8 Merge branch 'main' into issue-140601-iterparse-warning serhiy-storchaka Nov 13, 2025 https://github.com/python/cpython/pull/140603/commits/6c5c5e82c484b4bcac7bde34cc9b812ab0fa70b4
Clear filters https://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
Please reload this pagehttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
Please reload this pagehttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
Prev https://github.com/python/cpython/pull/140603/commits/fcd7ca09a77f22aa6362bce805746c4254d0a5ec
Next https://github.com/python/cpython/pull/140603/commits/6e3b0711626669da8e458d09f1bd3fe9bef2876b
Please reload this pagehttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965
https://github.com/osamakader
osamakaderhttps://github.com/python/cpython/commits?author=osamakader
Lib/test/test_xml_etree.pyhttps://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965#diff-cd2315ff25ab49e653d363de2d213e390ecb1b01bbc86e2be3b700db4b0bf454
View file https://github.com/osamakader/cpython/blob/0f9b5094c712f8ca8093017140f1af78a191b965/Lib/test/test_xml_etree.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/140603/commits/{{ revealButtonHref }}
https://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965#diff-cd2315ff25ab49e653d363de2d213e390ecb1b01bbc86e2be3b700db4b0bf454
https://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965#diff-cd2315ff25ab49e653d363de2d213e390ecb1b01bbc86e2be3b700db4b0bf454
https://github.com/python/cpython/pull/140603/commits/0f9b5094c712f8ca8093017140f1af78a191b965#diff-cd2315ff25ab49e653d363de2d213e390ecb1b01bbc86e2be3b700db4b0bf454
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.