mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-22831: Use "with" to avoid possible fd leaks in tools (part 2). (GH-10927)
This commit is contained in:
parent
afbb7a371f
commit
172bb39452
27 changed files with 249 additions and 259 deletions
|
@ -47,10 +47,10 @@ def printsum(filename, out=sys.stdout):
|
|||
except IOError as msg:
|
||||
sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg))
|
||||
return 1
|
||||
if fnfilter:
|
||||
filename = fnfilter(filename)
|
||||
sts = printsumfp(fp, filename, out)
|
||||
fp.close()
|
||||
with fp:
|
||||
if fnfilter:
|
||||
filename = fnfilter(filename)
|
||||
sts = printsumfp(fp, filename, out)
|
||||
return sts
|
||||
|
||||
def printsumfp(fp, filename, out=sys.stdout):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue