GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-43292: Fix file leak in `ET.iterparse()` when not exhausted by jacobtylerwalls · Pull Request #31696 · python/cpython

Conversation

@jacobtylerwalls

@jacobtylerwalls jacobtylerwalls commented Mar 5, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

bpo-43292: This fixes the file leak in xml.etree.ElementTree.iterparse when the iterator is garbage collected before being exhausted.

Regression test fails on main.


Related, but not done in this PR: bpo-25707 is a request for an explicit close() method for iterparse(). I am not certain if that feature would still be desired after this change.

https://bugs.python.org/issue43292

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jacobtylerwalls
bpo-43292: Fix file leak in iterparse when not exhausted
1495ccd
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 5, 2022
serhiy-storchaka
serhiy-storchaka reviewed Mar 6, 2022
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if pass a path of non-existing file to iterparse(),

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
serhiy-storchaka
serhiy-storchaka approved these changes Mar 6, 2022
View reviewed changes
@bedevere-bot bedevere-bot added the awaiting merge label Mar 6, 2022
@serhiy-storchaka
serhiy-storchaka self-requested a review March 6, 2022 11:56
@serhiy-storchaka
Update ElementTree.py
b29dba7
serhiy-storchaka
serhiy-storchaka reviewed Mar 6, 2022
View reviewed changes
Comment thread Lib/test/test_xml_etree.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
Update Lib/test/test_xml_etree.py
f532022
@serhiy-storchaka
serhiy-storchaka merged commit 496c428 into python:main Mar 7, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Mar 7, 2022
@serhiy-storchaka serhiy-storchaka added needs backport to 3.9 type-bug An unexpected behavior, bug, or error labels Mar 7, 2022
@miss-islington

miss-islington commented Mar 7, 2022

Copy link
Copy Markdown
Contributor

Thanks @jacobtylerwalls for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Mar 7, 2022

Copy link
Copy Markdown
Contributor

Thanks @jacobtylerwalls for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 7, 2022
@jacobtylerwalls @miss-islington
bpo-43292: Fix file leak in ET.iterparse() when not exhausted (pyth…
830d89d
…onGH-31696)

Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit 496c428)

Co-authored-by: Jacob Walls <[email protected]>
@bedevere-bot

bedevere-bot commented Mar 7, 2022

Copy link
Copy Markdown

GH-31720 is a backport of this pull request to the 3.9 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed needs backport to 3.9 labels Mar 7, 2022
@bedevere-bot

bedevere-bot commented Mar 7, 2022

Copy link
Copy Markdown

GH-31721 is a backport of this pull request to the 3.10 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 7, 2022
@jacobtylerwalls @miss-islington
bpo-43292: Fix file leak in ET.iterparse() when not exhausted (pyth…
ded8ce1
…onGH-31696)

Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit 496c428)

Co-authored-by: Jacob Walls <[email protected]>
miss-islington added a commit that referenced this pull request Mar 7, 2022
@miss-islington @jacobtylerwalls
bpo-43292: Fix file leak in ET.iterparse() when not exhausted (GH-3…
8acbb93
…1696)

Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit 496c428)

Co-authored-by: Jacob Walls <[email protected]>
serhiy-storchaka pushed a commit that referenced this pull request Mar 7, 2022
@miss-islington @jacobtylerwalls
[3.9] bpo-43292: Fix file leak in ET.iterparse() when not exhausted (…
852d9b7
…GH-31696) (GH-31720)

Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit 496c428)

Co-authored-by: Jacob Walls <[email protected]>
@jacobtylerwalls
jacobtylerwalls deleted the iterparse-file-cleanup branch March 7, 2022 13:02
@serhiy-storchaka serhiy-storchaka mentioned this pull request May 10, 2022
Add the close method for ElementTree.iterparse() object #69893
Closed
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
@miss-islington @jacobtylerwalls @hello-adam
[3.9] bpo-43292: Fix file leak in ET.iterparse() when not exhausted (…
27ecbd5
…pythonGH-31696) (pythonGH-31720)

Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit 496c428)

Co-authored-by: Jacob Walls <[email protected]>
@colesbury colesbury mentioned this pull request Jan 30, 2023
ElementTree.iterparse "leaks" file descriptor when not exhausted #101438
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@jacobtylerwalls @miss-islington @bedevere-bot @serhiy-storchaka @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.