[Python-checkins] cpython (3.3): Fix ResourceWarnings in test_sax

antoine.pitrou python-checkins at python.org
Mon May 13 22:35:46 CEST 2013


http://hg.python.org/cpython/rev/6481f819e6f0
changeset:   83765:6481f819e6f0
branch:      3.3
parent:      83763:c1383ddf7cb9
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Mon May 13 22:34:21 2013 +0200
summary:
  Fix ResourceWarnings in test_sax

files:
  Lib/test/test_sax.py |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -574,7 +574,10 @@
     def ioclass(self):
         writer = codecs.open(self.fname, 'w', encoding='ascii',
                              errors='xmlcharrefreplace', buffering=0)
-        self.addCleanup(support.unlink, self.fname)
+        def cleanup():
+            writer.close()
+            support.unlink(self.fname)
+        self.addCleanup(cleanup)
         writer.getvalue = self.getvalue
         return writer
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list