mirror of
https://github.com/python/cpython.git
synced 2025-08-29 21:25:01 +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
|
@ -45,9 +45,8 @@ def main():
|
|||
if filename == '-':
|
||||
process(sys.stdin, sys.stdout)
|
||||
else:
|
||||
f = open(filename, 'r')
|
||||
process(f, sys.stdout)
|
||||
f.close()
|
||||
with open(filename) as f:
|
||||
process(f, sys.stdout)
|
||||
|
||||
def process(fpi, fpo):
|
||||
keywords = ('if', 'ifdef', 'ifndef', 'else', 'endif')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue