Skip to content

Commit 4f0651e

Browse files
authored
Drop support for old frameworks (#4246)
- trytond<5, falcon<3, django<2 are all more than 5 years old Closes #4049
1 parent 43133b3 commit 4f0651e

File tree

9 files changed

+34
-89
lines changed

9 files changed

+34
-89
lines changed

MIGRATION_GUIDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
162162
- The `span` argument of `Scope.trace_propagation_meta` is no longer supported.
163163
- Setting `Scope.user` directly is no longer supported. Use `Scope.set_user()` instead.
164164
- `start_transaction` (`start_span`) no longer takes a `baggage` argument. Use the `continue_trace()` context manager instead to propagate baggage.
165+
- Dropped support for Django versions below 2.0.
166+
- Dropped support for trytond versions below 5.0.
167+
- Dropped support for Falcon versions below 3.0.
165168

166169
### Deprecated
167170

scripts/populate_tox/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"package": "django",
3434
"deps": {
3535
"*": [
36+
"channels[daphne]",
3637
"psycopg2-binary",
3738
"djangorestframework",
3839
"pytest-django",
@@ -45,7 +46,6 @@
4546
"Werkzeug<2.1.0",
4647
],
4748
"<3.1": ["pytest-django<4.0"],
48-
">=2.0": ["channels[daphne]"],
4949
},
5050
},
5151
"dramatiq": {

sentry_sdk/integrations/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ def iter_default_integrations(with_auto_enabling_integrations):
132132
"celery": (4, 4, 7),
133133
"chalice": (1, 16, 0),
134134
"clickhouse_driver": (0, 2, 0),
135-
"django": (1, 8),
135+
"django": (2, 0),
136136
"dramatiq": (1, 9),
137-
"falcon": (1, 4),
137+
"falcon": (3, 0),
138138
"fastapi": (0, 79, 0),
139139
"flask": (1, 1, 4),
140140
"gql": (3, 4, 1),
@@ -157,6 +157,7 @@ def iter_default_integrations(with_auto_enabling_integrations):
157157
"statsig": (0, 55, 3),
158158
"strawberry": (0, 209, 5),
159159
"tornado": (6, 0),
160+
"trytond": (5, 0),
160161
"typer": (0, 15),
161162
"unleash": (6, 0, 1),
162163
}

sentry_sdk/integrations/django/__init__.py

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
except ImportError:
5757
raise DidNotEnable("Django not installed")
5858

59+
from sentry_sdk.integrations.django.caching import patch_caching
5960
from sentry_sdk.integrations.django.transactions import LEGACY_RESOLVER
6061
from sentry_sdk.integrations.django.templates import (
6162
get_template_frame_from_exception,
@@ -65,11 +66,6 @@
6566
from sentry_sdk.integrations.django.signals_handlers import patch_signals
6667
from sentry_sdk.integrations.django.views import patch_views
6768

68-
if DJANGO_VERSION[:2] > (1, 8):
69-
from sentry_sdk.integrations.django.caching import patch_caching
70-
else:
71-
patch_caching = None # type: ignore
72-
7369
from typing import TYPE_CHECKING
7470

7571
if TYPE_CHECKING:
@@ -90,19 +86,6 @@
9086
from sentry_sdk._types import Event, Hint, EventProcessor, NotImplementedType
9187

9288

93-
if DJANGO_VERSION < (1, 10):
94-
95-
def is_authenticated(request_user):
96-
# type: (Any) -> bool
97-
return request_user.is_authenticated()
98-
99-
else:
100-
101-
def is_authenticated(request_user):
102-
# type: (Any) -> bool
103-
return request_user.is_authenticated
104-
105-
10689
TRANSACTION_STYLE_VALUES = ("function_name", "url")
10790

10891

@@ -599,7 +582,7 @@ def _set_user_info(request, event):
599582

600583
user = getattr(request, "user", None)
601584

602-
if user is None or not is_authenticated(user):
585+
if user is None or not user.is_authenticated:
603586
return
604587

605588
try:
@@ -626,20 +609,11 @@ def install_sql_hook():
626609
except ImportError:
627610
from django.db.backends.util import CursorWrapper
628611

629-
try:
630-
# django 1.6 and 1.7 compatability
631-
from django.db.backends import BaseDatabaseWrapper
632-
except ImportError:
633-
# django 1.8 or later
634-
from django.db.backends.base.base import BaseDatabaseWrapper
612+
from django.db.backends.base.base import BaseDatabaseWrapper
635613

636-
try:
637-
real_execute = CursorWrapper.execute
638-
real_executemany = CursorWrapper.executemany
639-
real_connect = BaseDatabaseWrapper.connect
640-
except AttributeError:
641-
# This won't work on Django versions < 1.6
642-
return
614+
real_execute = CursorWrapper.execute
615+
real_executemany = CursorWrapper.executemany
616+
real_connect = BaseDatabaseWrapper.connect
643617

644618
@ensure_integration_enabled(DjangoIntegration, real_execute)
645619
def execute(self, sql, params=None):

sentry_sdk/integrations/django/templates.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import functools
22

33
from django.template import TemplateSyntaxError
4+
from django.template.base import Origin
45
from django.utils.safestring import mark_safe
5-
from django import VERSION as DJANGO_VERSION
66

77
import sentry_sdk
88
from sentry_sdk.consts import OP
@@ -17,13 +17,6 @@
1717
from typing import Iterator
1818
from typing import Tuple
1919

20-
try:
21-
# support Django 1.9
22-
from django.template.base import Origin
23-
except ImportError:
24-
# backward compatibility
25-
from django.template.loader import LoaderOrigin as Origin
26-
2720

2821
def get_template_frame_from_exception(exc_value):
2922
# type: (Optional[BaseException]) -> Optional[Dict[str, Any]]
@@ -81,8 +74,6 @@ def rendered_content(self):
8174

8275
SimpleTemplateResponse.rendered_content = rendered_content
8376

84-
if DJANGO_VERSION < (1, 7):
85-
return
8677
import django.shortcuts
8778

8879
real_render = django.shortcuts.render

sentry_sdk/integrations/django/transactions.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@
1919
from typing import Union
2020
from re import Pattern
2121

22-
from django import VERSION as DJANGO_VERSION
23-
24-
if DJANGO_VERSION >= (2, 0):
25-
from django.urls.resolvers import RoutePattern
26-
else:
27-
RoutePattern = None
22+
from django.urls.resolvers import RoutePattern
2823

2924
try:
3025
from django.urls import get_resolver

sentry_sdk/integrations/falcon.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
from sentry_sdk._types import Event, EventProcessor
2121

22-
# In Falcon 3.0 `falcon.api_helpers` is renamed to `falcon.app_helpers`
23-
# and `falcon.API` to `falcon.App`
2422

2523
try:
2624
import falcon # type: ignore
@@ -29,24 +27,15 @@
2927
except ImportError:
3028
raise DidNotEnable("Falcon not installed")
3129

32-
try:
33-
import falcon.app_helpers # type: ignore
34-
35-
falcon_helpers = falcon.app_helpers
36-
falcon_app_class = falcon.App
37-
FALCON3 = True
38-
except ImportError:
39-
import falcon.api_helpers # type: ignore
30+
import falcon.app_helpers # type: ignore
4031

41-
falcon_helpers = falcon.api_helpers
42-
falcon_app_class = falcon.API
43-
FALCON3 = False
32+
falcon_helpers = falcon.app_helpers
33+
falcon_app_class = falcon.App
4434

4535

4636
_FALCON_UNSET = None # type: Optional[object]
47-
if FALCON3: # falcon.request._UNSET is only available in Falcon 3.0+
48-
with capture_internal_exceptions():
49-
from falcon.request import _UNSET as _FALCON_UNSET # type: ignore[import-not-found, no-redef]
37+
with capture_internal_exceptions():
38+
from falcon.request import _UNSET as _FALCON_UNSET # type: ignore[import-not-found, no-redef]
5039

5140

5241
class FalconRequestExtractor(RequestExtractor):
@@ -232,14 +221,7 @@ def _exception_leads_to_http_5xx(ex, response):
232221
ex, (falcon.HTTPError, falcon.http_status.HTTPStatus)
233222
)
234223

235-
# We only check the HTTP status on Falcon 3 because in Falcon 2, the status on the response
236-
# at the stage where we capture it is listed as 200, even though we would expect to see a 500
237-
# status. Since at the time of this change, Falcon 2 is ca. 4 years old, we have decided to
238-
# only perform this check on Falcon 3+, despite the risk that some handled errors might be
239-
# reported to Sentry as unhandled on Falcon 2.
240-
return (is_server_error or is_unhandled_error) and (
241-
not FALCON3 or _has_http_5xx_status(response)
242-
)
224+
return (is_server_error or is_unhandled_error) and _has_http_5xx_status(response)
243225

244226

245227
def _has_http_5xx_status(response):

sentry_sdk/integrations/trytond.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import sentry_sdk
2-
from sentry_sdk.integrations import Integration
2+
from sentry_sdk.integrations import _check_minimum_version, Integration
33
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
44
from sentry_sdk.utils import ensure_integration_enabled, event_from_exception
55

6+
from trytond import __version__ as trytond_version # type: ignore
67
from trytond.exceptions import TrytonException # type: ignore
78
from trytond.wsgi import app # type: ignore
89

@@ -19,6 +20,8 @@ def __init__(self): # type: () -> None
1920

2021
@staticmethod
2122
def setup_once(): # type: () -> None
23+
_check_minimum_version(TrytondWSGIIntegration, trytond_version)
24+
2225
app.wsgi_app = SentryWsgiMiddleware(
2326
app.wsgi_app,
2427
span_origin=TrytondWSGIIntegration.origin,

tox.ini

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# The file (and all resulting CI YAMLs) then need to be regenerated via
1111
# "scripts/generate-test-files.sh".
1212
#
13-
# Last generated: 2025-04-04T12:20:40.475012+00:00
13+
# Last generated: 2025-04-04T13:09:23.106982+00:00
1414

1515
[tox]
1616
requires =
@@ -227,7 +227,7 @@ envlist =
227227

228228

229229
# ~~~ Web 1 ~~~
230-
{py3.7}-django-v1.11.29
230+
{py3.7}-django-v2.0.9
231231
{py3.7,py3.8,py3.9}-django-v2.2.28
232232
{py3.7,py3.9,py3.10}-django-v3.2.25
233233
{py3.8,py3.11,py3.12}-django-v4.2.20
@@ -249,7 +249,7 @@ envlist =
249249
{py3.7}-bottle-v0.12.25
250250
{py3.7,py3.8,py3.9}-bottle-v0.13.2
251251

252-
{py3.7}-falcon-v2.0.0
252+
{py3.7,py3.8,py3.9}-falcon-v3.0.1
253253
{py3.7,py3.11,py3.12}-falcon-v3.1.3
254254
{py3.8,py3.11,py3.12}-falcon-v4.0.2
255255

@@ -601,12 +601,13 @@ deps =
601601

602602

603603
# ~~~ Web 1 ~~~
604-
django-v1.11.29: django==1.11.29
604+
django-v2.0.9: django==2.0.9
605605
django-v2.2.28: django==2.2.28
606606
django-v3.2.25: django==3.2.25
607607
django-v4.2.20: django==4.2.20
608608
django-v5.0.9: django==5.0.9
609609
django-v5.2: django==5.2
610+
django: channels[daphne]
610611
django: psycopg2-binary
611612
django: djangorestframework
612613
django: pytest-django
@@ -616,19 +617,14 @@ deps =
616617
django-v5.0.9: pytest-asyncio
617618
django-v5.2: pytest-asyncio
618619
django-v2.2.28: six
619-
django-v1.11.29: djangorestframework>=3.0,<4.0
620-
django-v1.11.29: Werkzeug<2.1.0
620+
django-v2.0.9: djangorestframework>=3.0,<4.0
621+
django-v2.0.9: Werkzeug<2.1.0
621622
django-v2.2.28: djangorestframework>=3.0,<4.0
622623
django-v2.2.28: Werkzeug<2.1.0
623624
django-v3.2.25: djangorestframework>=3.0,<4.0
624625
django-v3.2.25: Werkzeug<2.1.0
625-
django-v1.11.29: pytest-django<4.0
626+
django-v2.0.9: pytest-django<4.0
626627
django-v2.2.28: pytest-django<4.0
627-
django-v2.2.28: channels[daphne]
628-
django-v3.2.25: channels[daphne]
629-
django-v4.2.20: channels[daphne]
630-
django-v5.0.9: channels[daphne]
631-
django-v5.2: channels[daphne]
632628

633629
flask-v1.1.4: flask==1.1.4
634630
flask-v2.3.3: flask==2.3.3
@@ -660,7 +656,7 @@ deps =
660656
bottle-v0.13.2: bottle==0.13.2
661657
bottle: werkzeug<2.1.0
662658

663-
falcon-v2.0.0: falcon==2.0.0
659+
falcon-v3.0.1: falcon==3.0.1
664660
falcon-v3.1.3: falcon==3.1.3
665661
falcon-v4.0.2: falcon==4.0.2
666662

0 commit comments

Comments
 (0)