diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-03-30 06:33:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-30 06:33:02 (GMT) |
commit | 172bb39452ae8b3ccdf5d1f23ead46f44200cd49 (patch) | |
tree | 5e1effbca3664b839a81eb7a7d62fa4974cfbfb1 /Tools/scripts/nm2def.py | |
parent | afbb7a371fb44edc731344eab5b474ad8f7b57d7 (diff) | |
download | cpython-172bb39452ae8b3ccdf5d1f23ead46f44200cd49.zip cpython-172bb39452ae8b3ccdf5d1f23ead46f44200cd49.tar.gz cpython-172bb39452ae8b3ccdf5d1f23ead46f44200cd49.tar.bz2 |
bpo-22831: Use "with" to avoid possible fd leaks in tools (part 2). (GH-10927)
Diffstat (limited to 'Tools/scripts/nm2def.py')
-rwxr-xr-x | Tools/scripts/nm2def.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Tools/scripts/nm2def.py b/Tools/scripts/nm2def.py index 83bbcd7..a885ebd 100755 --- a/Tools/scripts/nm2def.py +++ b/Tools/scripts/nm2def.py @@ -42,7 +42,8 @@ NM = 'nm -p -g %s' # For Linux, use "nm -g %s" def symbols(lib=PYTHONLIB,types=('T','C','D')): - lines = os.popen(NM % lib).readlines() + with os.popen(NM % lib) as pipe: + lines = pipe.readlines() lines = [s.strip() for s in lines] symbols = {} for line in lines: @@ -97,7 +98,7 @@ def main(): exports = export_list(s) f = sys.stdout # open('PC/python_nt.def','w') f.write(DEF_TEMPLATE % (exports)) - f.close() + # f.close() if __name__ == '__main__': main() |