From 3fbfbad79fe294918459b70eb409d555b20de2c8 Mon Sep 17 00:00:00 2001 From: David Lord Date: Tue, 2 May 2023 07:05:51 -0700 Subject: [PATCH] werkzeug 2.3.3 compatibility --- CHANGES.rst | 2 ++ src/flask/testing.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 471d8e2232..ee9acf7759 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,8 @@ Version 2.2.5 Unreleased +- Update for compatibility with Werkzeug 2.3.3. + Version 2.2.4 ------------- diff --git a/src/flask/testing.py b/src/flask/testing.py index a972a3f5e9..b78ec6d49d 100644 --- a/src/flask/testing.py +++ b/src/flask/testing.py @@ -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 )