aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/j2objc
diff options
context:
space:
mode:
authorGravatar laszlocsomor <laszlocsomor@google.com>2018-07-05 01:58:06 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-05 02:00:15 -0700
commitf11c6bcab87ee8927e23a23d2300900a0922616d (patch)
tree64b31cedc598400dbeabd00f2fa05f7d875c8b9e /tools/j2objc
parent195c4e4c8fb3d4c6b1b3790b07266b0a5ff51d80 (diff)
python tools: ensure files are closed
Use the "with" statement to open files in various Python scripts used by Bazel, to ensure these files are closed eagerly. See https://github.com/bazelbuild/bazel/issues/5512 RELNOTES: none PiperOrigin-RevId: 203346678
Diffstat (limited to 'tools/j2objc')
-rwxr-xr-xtools/j2objc/j2objc_wrapper.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/tools/j2objc/j2objc_wrapper.py b/tools/j2objc/j2objc_wrapper.py
index bc142d4656..339f092446 100755
--- a/tools/j2objc/j2objc_wrapper.py
+++ b/tools/j2objc/j2objc_wrapper.py
@@ -125,11 +125,10 @@ def WriteDepMappingFile(objc_files,
entry_file, deps = output_dep_mapping_queue.get()
dep_mapping[entry_file] = deps
- f = file_open(output_dependency_mapping_file, 'w')
- for entry in sorted(dep_mapping):
- for dep in dep_mapping[entry]:
- f.write(entry + ':' + dep + '\n')
- f.close()
+ with file_open(output_dependency_mapping_file, 'w') as f:
+ for entry in sorted(dep_mapping):
+ for dep in dep_mapping[entry]:
+ f.write(entry + ':' + dep + '\n')
def _ReadDepMapping(input_file_queue, output_dep_mapping_queue,