bpo-22831: Use "with" to avoid possible fd leaks in tools (part 2). (GH-10927)

This commit is contained in:
Serhiy Storchaka 2019-03-30 08:33:02 +02:00 committed by GitHub
parent afbb7a371f
commit 172bb39452
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 249 additions and 259 deletions

View file

@ -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()