Skip to content

Commit e26d7b8

Browse files
authored
fix(django): Patch __self__ onto middlewares (#773)
Fix #661
1 parent fc3f747 commit e26d7b8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sentry_sdk/integrations/django/middleware.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,14 @@ def sentry_wrapped_method(*args, **kwargs):
9191

9292
try:
9393
# fails for __call__ of function on Python 2 (see py2.7-django-1.11)
94-
return wraps(old_method)(sentry_wrapped_method) # type: ignore
94+
sentry_wrapped_method = wraps(old_method)(sentry_wrapped_method)
95+
96+
# Necessary for Django 3.1
97+
sentry_wrapped_method.__self__ = old_method.__self__ # type: ignore
9598
except Exception:
96-
return sentry_wrapped_method # type: ignore
99+
pass
100+
101+
return sentry_wrapped_method # type: ignore
97102

98103
return old_method
99104

0 commit comments

Comments
 (0)