Explicitly close some files (from issue #10093)

This commit is contained in:
Antoine Pitrou 2010-10-14 21:15:17 +00:00
parent d9f57630fe
commit b86680e299
6 changed files with 31 additions and 14 deletions

View file

@ -383,7 +383,8 @@ def main():
if o == '-u': func = decode
if o == '-t': test(); return
if args and args[0] != '-':
func(open(args[0], 'rb'), sys.stdout.buffer)
with open(args[0], 'rb') as f:
func(f, sys.stdout.buffer)
else:
func(sys.stdin.buffer, sys.stdout.buffer)