From a54fc55fc0130407bd1b5ce9b4cc909ce1796d68 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Tue, 29 Oct 2024 10:20:44 -0400 Subject: [PATCH] Update Starlette/python-multipart patch as merged upstream --- ...8e6c4eedf046c601b81d5d8d82f92115eddd.patch | 33 ++++++++++++++ 3710.patch | 43 ------------------- python-sentry-sdk.spec | 7 ++- 3 files changed, 39 insertions(+), 44 deletions(-) create mode 100644 000c8e6c4eedf046c601b81d5d8d82f92115eddd.patch delete mode 100644 3710.patch diff --git a/000c8e6c4eedf046c601b81d5d8d82f92115eddd.patch b/000c8e6c4eedf046c601b81d5d8d82f92115eddd.patch new file mode 100644 index 0000000..2d6a60f --- /dev/null +++ b/000c8e6c4eedf046c601b81d5d8d82f92115eddd.patch @@ -0,0 +1,33 @@ +From 000c8e6c4eedf046c601b81d5d8d82f92115eddd Mon Sep 17 00:00:00 2001 +From: Ben Beasley +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 +--- + 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 + diff --git a/3710.patch b/3710.patch deleted file mode 100644 index 73f77b0..0000000 --- a/3710.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 331c7a7b3c45864950055c12597c78c560234807 Mon Sep 17 00:00:00 2001 -From: "Benjamin A. Beasley" -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 diff --git a/python-sentry-sdk.spec b/python-sentry-sdk.spec index 3f69310..6b30e65 100644 --- a/python-sentry-sdk.spec +++ b/python-sentry-sdk.spec @@ -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