Skip to content

Commit

Permalink
werkzeug 2.3.3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed May 2, 2023
1 parent 726d3f4 commit 3fbfbad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Version 2.2.5

Unreleased

- Update for compatibility with Werkzeug 2.3.3.


Version 2.2.4
-------------
Expand Down
17 changes: 14 additions & 3 deletions src/flask/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,21 @@ def session_transaction(
app.session_interface.save_session(app, sess, resp)

if hasattr(self, "_update_cookies_from_response"):
self._update_cookies_from_response(
ctx.request.host.partition(":")[0], resp.headers.getlist("Set-Cookie")
)
try:
# Werkzeug>=2.3.3
self._update_cookies_from_response(
ctx.request.host.partition(":")[0],
ctx.request.path,
resp.headers.getlist("Set-Cookie"),
)
except TypeError:
# Werkzeug>=2.3.0,<2.3.3
self._update_cookies_from_response( # type: ignore[call-arg]
ctx.request.host.partition(":")[0],
resp.headers.getlist("Set-Cookie"), # type: ignore[arg-type]
)
else:
# Werkzeug<2.3.0
self.cookie_jar.extract_wsgi( # type: ignore[union-attr]
ctx.request.environ, resp.headers
)
Expand Down

0 comments on commit 3fbfbad

Please sign in to comment.