diff options
Diffstat (limited to 'test/explain/basic.py')
-rw-r--r-- | test/explain/basic.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/explain/basic.py b/test/explain/basic.py index 99942cd..160d632 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -67,13 +67,15 @@ def process(outfp, infp): print("os.getcwd() =", os.getcwd()) raise process(outfp, fp) + fp.close() else: outfp.write(line) -outfp = open(sys.argv[1], 'w') -for f in sys.argv[2:]: - if f != '-': - process(outfp, open(f, 'r')) +with open(sys.argv[1], 'w') as ofp: + for f in sys.argv[2:]: + if f != '-': + with open(f, 'r') as ifp: + process(ofp, ifp) sys.exit(0) """) |