summaryrefslogtreecommitdiff
path: root/giscanner/gdumpparser.py
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2015-07-05 10:54:16 +0200
committerEmmanuele Bassi <ebassi@gnome.org>2015-08-21 13:03:01 +0100
commitebe658542217c510f186dfc68956d51528d81fd6 (patch)
treec55847c5418430a9b4e509713bb487f358545820 /giscanner/gdumpparser.py
parent23e5dd8d6821e269feec3346c5f95c390a4ff009 (diff)
downloadgobject-introspection-ebe658542217c510f186dfc68956d51528d81fd6.tar.gz
scanner: use open() as os.fdopen as context managers
Ensures files are correctly and immediately closed. https://bugzilla.gnome.org/show_bug.cgi?id=751926
Diffstat (limited to 'giscanner/gdumpparser.py')
-rw-r--r--giscanner/gdumpparser.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/giscanner/gdumpparser.py b/giscanner/gdumpparser.py
index b49ceef1..179bbd83 100644
--- a/giscanner/gdumpparser.py
+++ b/giscanner/gdumpparser.py
@@ -145,16 +145,15 @@ class GDumpParser(object):
"""Load the library (or executable), returning an XML
blob containing data gleaned from GObject's primitive introspection."""
in_path = os.path.join(self._binary.tmpdir, 'functions.txt')
- f = open(in_path, 'w')
- for func in self._get_type_functions:
- f.write('get-type:')
- f.write(func)
- f.write('\n')
- for func in self._error_quark_functions:
- f.write('error-quark:')
- f.write(func)
- f.write('\n')
- f.close()
+ with open(in_path, 'w') as f:
+ for func in self._get_type_functions:
+ f.write('get-type:')
+ f.write(func)
+ f.write('\n')
+ for func in self._error_quark_functions:
+ f.write('error-quark:')
+ f.write(func)
+ f.write('\n')
out_path = os.path.join(self._binary.tmpdir, 'dump.xml')
args = []