summaryrefslogtreecommitdiff
path: root/sphinx/quickstart.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/quickstart.py')
-rw-r--r--sphinx/quickstart.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index 83fd2f449..5ee5cc7fe 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -1487,11 +1487,8 @@ def generate(d, overwrite=True, silent=False):
def write_file(fpath, content, newline=None):
if overwrite or not path.isfile(fpath):
print('Creating file %s.' % fpath)
- f = open(fpath, 'wt', encoding='utf-8', newline=newline)
- try:
+ with open(fpath, 'wt', encoding='utf-8', newline=newline) as f:
f.write(content)
- finally:
- f.close()
else:
print('File %s already exists, skipping.' % fpath)