Skip to content

Commit adedb2a

Browse files
authored
Merge pull request #5101 from pallets/update-werkzeug
update werkzeug to >=2.3.3
2 parents 37badc3 + e1aedec commit adedb2a

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

CHANGES.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Version 2.3.2
33

44
Unreleased
55

6-
- Session cookie sets ``Vary: Cookie`` header when it is accessed, modified, cleared,
7-
or refreshed.
6+
- Set ``Vary: Cookie`` header when the session is accessed, modified, or refreshed.
7+
- Update Werkzeug requirement to >=2.3.3 to apply recent bug fixes.
88

99

1010
Version 2.3.1

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers = [
2020
]
2121
requires-python = ">=3.8"
2222
dependencies = [
23-
"Werkzeug>=2.3.0",
23+
"Werkzeug>=2.3.3",
2424
"Jinja2>=3.1.2",
2525
"itsdangerous>=2.1.2",
2626
"click>=8.1.3",

src/flask/testing.py

+7-17
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,14 @@ def session_transaction(
138138
:meth:`~flask.Flask.test_request_context` which are directly
139139
passed through.
140140
"""
141-
# new cookie interface for Werkzeug >= 2.3
142-
cookie_storage = self._cookies if hasattr(self, "_cookies") else self.cookie_jar
143-
144-
if cookie_storage is None:
141+
if self._cookies is None:
145142
raise TypeError(
146143
"Cookies are disabled. Create a client with 'use_cookies=True'."
147144
)
148145

149146
app = self.application
150147
ctx = app.test_request_context(*args, **kwargs)
151-
152-
if hasattr(self, "_add_cookies_to_wsgi"):
153-
self._add_cookies_to_wsgi(ctx.request.environ)
154-
else:
155-
self.cookie_jar.inject_wsgi(ctx.request.environ) # type: ignore[union-attr]
148+
self._add_cookies_to_wsgi(ctx.request.environ)
156149

157150
with ctx:
158151
sess = app.session_interface.open_session(app, ctx.request)
@@ -169,14 +162,11 @@ def session_transaction(
169162
with ctx:
170163
app.session_interface.save_session(app, sess, resp)
171164

172-
if hasattr(self, "_update_cookies_from_response"):
173-
self._update_cookies_from_response(
174-
ctx.request.host.partition(":")[0], resp.headers.getlist("Set-Cookie")
175-
)
176-
else:
177-
self.cookie_jar.extract_wsgi( # type: ignore[union-attr]
178-
ctx.request.environ, resp.headers
179-
)
165+
self._update_cookies_from_response(
166+
ctx.request.host.partition(":")[0],
167+
ctx.request.path,
168+
resp.headers.getlist("Set-Cookie"),
169+
)
180170

181171
def _copy_environ(self, other):
182172
out = {**self.environ_base, **other}

0 commit comments

Comments
 (0)