Skip to content

Commit 4e652d3

Browse files
authored
Abort if the instance folder cannot be created (#5903)
2 parents 407eb76 + 3d03098 commit 4e652d3

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

docs/tutorial/factory.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ directory should be treated as a package.
5656
app.config.from_mapping(test_config)
5757
5858
# ensure the instance folder exists
59-
try:
60-
os.makedirs(app.instance_path)
61-
except OSError:
62-
pass
59+
os.makedirs(app.instance_path, exist_ok=True)
6360
6461
# a simple page that says hello
6562
@app.route('/hello')

examples/tutorial/flaskr/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ def create_app(test_config=None):
2121
app.config.update(test_config)
2222

2323
# ensure the instance folder exists
24-
try:
25-
os.makedirs(app.instance_path)
26-
except OSError:
27-
pass
24+
os.makedirs(app.instance_path, exist_ok=True)
2825

2926
@app.route("/hello")
3027
def hello():

0 commit comments

Comments
 (0)