Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue25688

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:File leak in ElementTree.iterparse()
Type:resource usageStage:resolved
Components:Library (Lib)Versions:Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: eli.bendersky, martin.panter, python-dev, scoder, serhiy.storchaka
Priority:normalKeywords:patch

Created on2015-11-21 11:11 byserhiy.storchaka, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
etree_iterparse_leak.patchserhiy.storchaka,2015-11-21 11:11review
etree_iterparse_leak_2.patchserhiy.storchaka,2015-11-23 07:57review
Messages (6)
msg255051 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-11-21 11:11
ElementTree.iterparse() can leak internally open file in case of error. Proposed patch fixes the leak.
msg255127 -(view)Author: Martin Panter (martin.panter)*(Python committer)Date: 2015-11-23 06:08
What’s the point of the catch_warnings() and filterwarnings() calls in the tests? They don’t seem to be doing much; I think the CleanContext manager is already enabling warnings. Perhaps you could call simplefilter("error", ResourceWarning) instead.Also I’m not enthusiastic about the iterparse() API when passing a file name. If it has to stay, maybe there should be an explicit way to clean it up without exhausting the iterator, like a generator.close() method.
msg255136 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-11-23 07:57
Warning is emitted in destructor, and exceptions in destructors are ignored. Hence turning it into error makes the test passed.Tests were not correct, here is fixed patch.Yes, CleanContext does the work. But depending on it looks fragile. CleanContext can be removed after getting rid of all deprecated methods.I agree that we have to add the close() method to iterparse object. But this is new feature and separate issue.
msg255147 -(view)Author: Martin Panter (martin.panter)*(Python committer)Date: 2015-11-23 11:16
Patch 2 looks good. I like the new version of the tests better.
msg255157 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-11-23 13:47
New changeset6e23777948f3 by Serhiy Storchaka in branch '3.4':Issue#25688: Fixed file leak in ElementTree.iterparse() raising an error.https://hg.python.org/cpython/rev/6e23777948f3New changeset267d04459ba3 by Serhiy Storchaka in branch '3.5':Issue#25688: Fixed file leak in ElementTree.iterparse() raising an error.https://hg.python.org/cpython/rev/267d04459ba3New changesetd841205776fe by Serhiy Storchaka in branch 'default':Issue#25688: Fixed file leak in ElementTree.iterparse() raising an error.https://hg.python.org/cpython/rev/d841205776feNew changeset09a8ac75b351 by Serhiy Storchaka in branch '2.7':Issue#25688: Fixed file leak in ElementTree.iterparse() raising an error.https://hg.python.org/cpython/rev/09a8ac75b351
msg255160 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-11-23 13:58
Thank you for your review Martin. Openedissue25707 for adding the close method.
History
DateUserActionArgs
2022-04-11 14:58:24adminsetgithub: 69874
2015-11-23 13:58:32serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: +msg255160

stage: patch review -> resolved
2015-11-23 13:47:11python-devsetnosy: +python-dev
messages: +msg255157
2015-11-23 11:16:59martin.pantersetmessages: +msg255147
2015-11-23 07:57:42serhiy.storchakasetfiles: +etree_iterparse_leak_2.patch

messages: +msg255136
2015-11-23 06:08:16martin.pantersetnosy: +martin.panter
messages: +msg255127
2015-11-21 11:11:33serhiy.storchakacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp