Skip to content

Commit f79b4d6

Browse files
fix(wsgi): Do not catch None (#6229)
1 parent 7b68600 commit f79b4d6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

sentry_sdk/integrations/_wsgi_common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
try:
1111
from django.http.request import RawPostDataException
12+
13+
_RAW_DATA_EXCEPTIONS = (RawPostDataException, ValueError)
1214
except ImportError:
1315
RawPostDataException = None
16+
_RAW_DATA_EXCEPTIONS = (ValueError,)
1417

1518
from typing import TYPE_CHECKING
1619

@@ -110,7 +113,7 @@ def extract_into_event(self, event: "Event") -> None:
110113
raw_data = None
111114
try:
112115
raw_data = self.raw_data()
113-
except (RawPostDataException, ValueError):
116+
except _RAW_DATA_EXCEPTIONS:
114117
# If DjangoRestFramework is used it already read the body for us
115118
# so reading it here will fail. We can ignore this.
116119
pass
@@ -175,7 +178,7 @@ def json(self) -> "Optional[Any]":
175178

176179
try:
177180
raw_data = self.raw_data()
178-
except (RawPostDataException, ValueError):
181+
except _RAW_DATA_EXCEPTIONS:
179182
# The body might have already been read, in which case this will
180183
# fail
181184
raw_data = None

0 commit comments

Comments
 (0)