Update Starlette/python-multipart patch as merged upstream

This commit is contained in:
Benjamin A. Beasley 2024-10-29 10:20:44 -04:00
parent 3d87ddb258
commit a54fc55fc0
3 changed files with 39 additions and 44 deletions

View file

@ -0,0 +1,33 @@
From 000c8e6c4eedf046c601b81d5d8d82f92115eddd Mon Sep 17 00:00:00 2001
From: Ben Beasley <code@musicinmybrain.net>
Date: Tue, 29 Oct 2024 08:13:56 -0400
Subject: [PATCH] fix(starlette): Prefer python_multipart import over multipart
(#3710)
See also releases 0.0.13 through 0.0.16 at
https://github.com/Kludex/python-multipart/releases.
---------
Co-authored-by: Daniel Szoke <daniel.szoke@sentry.io>
---
sentry_sdk/integrations/starlette.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sentry_sdk/integrations/starlette.py b/sentry_sdk/integrations/starlette.py
index 52c64f6843..d9db8bd6b8 100644
--- a/sentry_sdk/integrations/starlette.py
+++ b/sentry_sdk/integrations/starlette.py
@@ -65,7 +65,12 @@
try:
# Optional dependency of Starlette to parse form data.
- import multipart # type: ignore
+ try:
+ # python-multipart 0.0.13 and later
+ import python_multipart as multipart # type: ignore
+ except ImportError:
+ # python-multipart 0.0.12 and earlier
+ import multipart # type: ignore
except ImportError:
multipart = None

View file

@ -1,43 +0,0 @@
From 331c7a7b3c45864950055c12597c78c560234807 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Mon, 28 Oct 2024 12:56:23 -0400
Subject: [PATCH] Prefer python_multipart import over multipart
See: https://github.com/Kludex/python-multipart/issues/16
See also releases 0.0.13 through 0.0.16 at
https://github.com/Kludex/python-multipart/releases.
---
sentry_sdk/integrations/starlette.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sentry_sdk/integrations/starlette.py b/sentry_sdk/integrations/starlette.py
index 52c64f6843..d1cad7a89b 100644
--- a/sentry_sdk/integrations/starlette.py
+++ b/sentry_sdk/integrations/starlette.py
@@ -65,9 +65,14 @@
try:
# Optional dependency of Starlette to parse form data.
- import multipart # type: ignore
+ try:
+ # python-multipart 0.0.13 and later
+ import python_multipart # type: ignore
+ except ImportError:
+ # python-multipart 0.0.12 and later
+ import multipart as python_multipart # type: ignore
except ImportError:
- multipart = None
+ python_multipart = None
_DEFAULT_TRANSACTION_NAME = "generic Starlette request"
@@ -657,7 +662,7 @@ def cookies(self):
async def form(self):
# type: (StarletteRequestExtractor) -> Any
- if multipart is None:
+ if python_multipart is None:
return None
# Parse the body first to get it cached, as Starlette does not cache form() as it

View file

@ -59,9 +59,14 @@ Patch1: 0001-Downstream-only-unpin-virtualenv.patch
# Prefer python_multipart import over multipart
# https://github.com/getsentry/sentry-python/pull/3710
#
# Merged as:
#
# fix(starlette): Prefer python_multipart import over multipart (#3710)
# https://github.com/getsentry/sentry-python/commit/000c8e6c4eedf046c601b81d5d8d82f92115eddd
#
# This avoids a PendingDeprecationError in the tests when using the multipart
# import name with python-multipart 0.0.13 or later.
Patch2: %{forgeurl}/pull/3710.patch
Patch2: %{forgeurl}/commit/000c8e6c4eedf046c601b81d5d8d82f92115eddd.patch
BuildArch: noarch
BuildRequires: python3-devel