From b724832872ae4b4cd4b5f61c153eae39f1c3b213 Mon Sep 17 00:00:00 2001 From: Joshua Bronson Date: Mon, 20 Apr 2020 13:26:33 -0400 Subject: [PATCH 1/5] Cherry-pick 7ba35c4 from master (support pathlib.Path for static_folder) --- CHANGES.rst | 11 +++++++++++ src/flask/helpers.py | 2 +- tests/test_basic.py | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index a85313eb..7fa83f76 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,5 +1,16 @@ .. currentmodule:: flask + + +Version 1.1.x +------------- + +Not yet released. + +- Officially support passing a :class:`pathlib.Path` for + ``static_folder`` which stopped working in 1.1.2. :pr:`3579` + + Version 1.1.2 ------------- diff --git a/src/flask/helpers.py b/src/flask/helpers.py index df06db86..3e64e3fa 100644 --- a/src/flask/helpers.py +++ b/src/flask/helpers.py @@ -1001,7 +1001,7 @@ class _PackageBoundObject(object): @static_folder.setter def static_folder(self, value): if value is not None: - value = value.rstrip("/\\") + value = os.fspath(value).rstrip(r"\/") self._static_folder = value @property diff --git a/tests/test_basic.py b/tests/test_basic.py index 4d3b7b08..58cbe3b7 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1425,6 +1425,16 @@ def test_static_url_empty_path_default(app): rv.close() +@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6") +def test_static_folder_with_pathlib_path(app): + from pathlib import Path + + app = flask.Flask(__name__, static_folder=Path("static")) + rv = app.test_client().open("/static/index.html", method="GET") + assert rv.status_code == 200 + rv.close() + + def test_static_folder_with_ending_slash(): app = flask.Flask(__name__, static_folder="static/") From 12a4d1554689c0a0ac13988b0daf10c23c37c81d Mon Sep 17 00:00:00 2001 From: Ebram Shehata Date: Sat, 26 Sep 2020 01:52:00 +0200 Subject: [PATCH 2/5] Update quickstart.rst (#3767) --- docs/quickstart.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 9b4fd7ba..5521472e 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -100,7 +100,7 @@ First of all you need to look at the error message. Old Version of Flask ```````````````````` -Versions of Flask older than 0.11 use to have different ways to start the +Versions of Flask older than 0.11 used to have different ways to start the application. In short, the :command:`flask` command did not exist, and neither did :command:`python -m flask`. In that case you have two options: either upgrade to newer Flask versions or have a look at the :ref:`server` From fa5aebc842c1cd19a57503984310db21aa512904 Mon Sep 17 00:00:00 2001 From: Henry Kobin Date: Sun, 11 Oct 2020 19:15:19 -0700 Subject: [PATCH 3/5] updated Sentry link (#3788) --- docs/errorhandling.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/errorhandling.rst b/docs/errorhandling.rst index b565aa3e..3de38103 100644 --- a/docs/errorhandling.rst +++ b/docs/errorhandling.rst @@ -66,7 +66,7 @@ Follow-up reads: similar fashion. See the `Python SDK docs `_ for more information. * `Getting started with Sentry `_ -* `Flask-specific documentation `_. +* `Flask-specific documentation `_. .. _error-handlers: From 9d824db41c930126db7bc6af5c54eec670cf086c Mon Sep 17 00:00:00 2001 From: Jamiu Salimon Date: Thu, 15 Oct 2020 22:02:54 +0100 Subject: [PATCH 4/5] Update the signature of the teardown function (#3730) Co-authored-by: David Lord --- docs/appcontext.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/appcontext.rst b/docs/appcontext.rst index 53c5ad36..628ddca6 100644 --- a/docs/appcontext.rst +++ b/docs/appcontext.rst @@ -119,7 +119,7 @@ For example, you can manage a database connection using this pattern:: return g.db @app.teardown_appcontext - def teardown_db(): + def teardown_db(exception): db = g.pop('db', None) if db is not None: From 577eec198adfb0a69f059e87c53d6ace55c55a77 Mon Sep 17 00:00:00 2001 From: Sarthak Vineet Kumar Date: Thu, 5 Nov 2020 07:50:36 +0530 Subject: [PATCH 5/5] updated doc for mod_wsgi (#3751) Co-authored-by: Sarthak --- docs/deploying/mod_wsgi.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/deploying/mod_wsgi.rst b/docs/deploying/mod_wsgi.rst index 76d986b7..a1a7333c 100644 --- a/docs/deploying/mod_wsgi.rst +++ b/docs/deploying/mod_wsgi.rst @@ -27,7 +27,7 @@ follows: .. sourcecode:: text - $ apt-get install libapache2-mod-wsgi + $ apt-get install libapache2-mod-wsgi-py3 If you are using a yum based distribution (Fedora, OpenSUSE, etc..) you can install it as follows: @@ -41,7 +41,7 @@ using pkg_add: .. sourcecode:: text - $ pkg install ap22-mod_wsgi2 + $ pkg install ap24-py37-mod_wsgi If you are using pkgsrc you can install `mod_wsgi` by compiling the `www/ap2-wsgi` package.