diff --git a/CHANGES.rst b/CHANGES.rst index 08fb9089f..75dbc2439 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,8 @@ Unreleased for 1xx, 204, 304, and HEAD responses. :issue:`2375` - Response HTML for exceptions and redirects starts with ```` and ````. :issue:`2390` +- Fix ability to set some ``cache_control`` attributes to ``False``. + :issue:`2379` Version 2.1.1 diff --git a/src/werkzeug/datastructures.py b/src/werkzeug/datastructures.py index d0da331d3..ed48d5936 100644 --- a/src/werkzeug/datastructures.py +++ b/src/werkzeug/datastructures.py @@ -2036,7 +2036,10 @@ def _set_cache_value(self, key, value, type): elif value is True: self[key] = None else: - self[key] = type(value) + if type is not None: + self[key] = type(value) + else: + self[key] = value def _del_cache_value(self, key): """Used internally by the accessor properties.""" diff --git a/tests/test_datastructures.py b/tests/test_datastructures.py index e69a65ff7..d036e72fd 100644 --- a/tests/test_datastructures.py +++ b/tests/test_datastructures.py @@ -973,6 +973,8 @@ def test_set_none(self): assert cc.no_cache is None cc.no_cache = None assert cc.no_cache is None + cc.no_cache = False + assert cc.no_cache is False class TestContentSecurityPolicy: