Revision: 3872
Author: pekka.klarck
Date: Mon Aug 23 08:43:52 2010
Log: close source also if parsing fails
http://code.google.com/p/robotframework/source/detail?r=3872

Modified:
 /trunk/src/robot/utils/domwrapper.py

=======================================
--- /trunk/src/robot/utils/domwrapper.py        Mon May 31 05:21:54 2010
+++ /trunk/src/robot/utils/domwrapper.py        Mon Aug 23 08:43:52 2010
@@ -57,9 +57,10 @@
             source = open(path, 'rb')
         else:
             source = StringIO(string)
-        node = ET.parse(source).getroot()
-        source.close()
-        return node
+        try:
+            return ET.parse(source).getroot()
+        finally:
+            source.close()

     def get_nodes(self, path):
         """Returns a list of descendants matching given 'path'.

Reply via email to