summaryrefslogtreecommitdiff
path: root/doc/_ext
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-10-20 07:58:57 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-10-20 07:58:57 -0400
commit6b6a4488adc12d390c5e0c8f13829dd9bf125309 (patch)
tree4eeeeb857c02023fd46d610612f600d533105afb /doc/_ext
parent2e5688eedd1576e9b100386c0a9ae30828123f73 (diff)
downloadpython-coveragepy-git-6b6a4488adc12d390c5e0c8f13829dd9bf125309.tar.gz
with statements: no more finally close
--HG-- branch : 4.0
Diffstat (limited to 'doc/_ext')
-rw-r--r--doc/_ext/px_cleaner.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/doc/_ext/px_cleaner.py b/doc/_ext/px_cleaner.py
index a5c00ff3..24541207 100644
--- a/doc/_ext/px_cleaner.py
+++ b/doc/_ext/px_cleaner.py
@@ -5,17 +5,11 @@ import sys
def clean_px(fname):
"""Clean a px file."""
- f = open(fname)
- try:
+ with open(fname) as f:
text = f.read()
- finally:
- f.close()
text = text.lstrip()
- f = open(fname, "w")
- try:
+ with open(fname, "w") as f:
f.write(text)
- finally:
- f.close()
def clean_px_files(fnames):
for fname in fnames:
@@ -23,4 +17,3 @@ def clean_px_files(fnames):
if __name__ == '__main__':
clean_px_files(sys.argv[1:])
-