Abort if the instance folder cannot be created

According to the comment, the instance folder should exist in any case.
But a PermissionError was ignored silently.

Since Python 3.9 is the minimum required version, it is safe to use
"exist_ok" added in Python 3.2 and avoid exception handling.
This commit is contained in:
Markus Heidelberg 2026-01-20 14:16:17 +01:00
parent 407eb76b27
commit 3d03098a97
2 changed files with 2 additions and 8 deletions

View file

@ -56,10 +56,7 @@ directory should be treated as a package.
app.config.from_mapping(test_config) app.config.from_mapping(test_config)
# ensure the instance folder exists # ensure the instance folder exists
try: os.makedirs(app.instance_path, exist_ok=True)
os.makedirs(app.instance_path)
except OSError:
pass
# a simple page that says hello # a simple page that says hello
@app.route('/hello') @app.route('/hello')

View file

@ -21,10 +21,7 @@ def create_app(test_config=None):
app.config.update(test_config) app.config.update(test_config)
# ensure the instance folder exists # ensure the instance folder exists
try: os.makedirs(app.instance_path, exist_ok=True)
os.makedirs(app.instance_path)
except OSError:
pass
@app.route("/hello") @app.route("/hello")
def hello(): def hello():