summaryrefslogtreecommitdiff
path: root/giscanner/docmain.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/docmain.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/docmain.py')
-rw-r--r--giscanner/docmain.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/giscanner/docmain.py b/giscanner/docmain.py
index fdcda18f..b5baf99e 100644
--- a/giscanner/docmain.py
+++ b/giscanner/docmain.py
@@ -60,9 +60,8 @@ def doc_main(args):
if args.write_sections:
sections_file = generate_sections_file(transformer)
- fp = open(args.output, 'w')
- write_sections_file(fp, sections_file)
- fp.close()
+ with open(args.output, 'w') as fp:
+ write_sections_file(fp, sections_file)
else:
writer = DocWriter(transformer, args.language)
writer.write(args.output)