Issue 8832: automate minidom.unlink() with a context manager (original) (raw)

Created on 2010-05-27 13:03 by kristjan.jonsson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
minidomcontext.patch kristjan.jonsson,2010-05-27 13:02
Messages (7)
msg106610 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2010-05-27 13:02
It is all to easy to forget to "unlink()" minidom documents resulting in huge memory usage. This patch allows to automate that process with a context manager, similar to how files can be closed in the same way: with xml.dom.minidom.parse() as dom: workwith(dom) will automatically call dom.unlink() when context manager is exited. Patch provided.
msg107339 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2010-06-08 19:57
Any comments?
msg107341 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2010-06-08 20:25
+1
msg107349 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-06-08 21:14
Looks good to me.
msg107350 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-06-08 21:15
The test passes if __exit__ doesn't call unlink. Otherwise the patch looks good to me.
msg107372 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2010-06-09 08:14
Thank you all. I updated the unittest, and committed this in: revision: 81856
msg107378 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-06-09 10:32
You forgot to close the bug :) Note that if you write “rNNNN” or “revision NNNN”, Roundup will make a link out of it.
History
Date User Action Args
2022-04-11 14:57:01 admin set github: 53078
2010-06-09 10:32:24 eric.araujo set status: open -> closedkeywords:patch, patch, easy, needs reviewresolution: acceptedmessages: +
2010-06-09 08:14:45 kristjan.jonsson set keywords:patch, patch, easy, needs reviewmessages: + stage: resolved
2010-06-08 21:15:46 r.david.murray set keywords:patch, patch, easy, needs reviewnosy: + r.david.murraymessages: +
2010-06-08 21:14:10 eric.araujo set keywords:patch, patch, easy, needs reviewnosy: + eric.araujomessages: +
2010-06-08 20:25:06 fdrake set keywords:patch, patch, easy, needs reviewnosy: + fdrakemessages: +
2010-06-08 19:57:42 kristjan.jonsson set keywords:patch, patch, easy, needs reviewmessages: +
2010-05-27 13:03:00 kristjan.jonsson create