diff --git a/requirements-testing.txt b/requirements-testing.txt index a6041972cd..acb3d4d700 100644 --- a/requirements-testing.txt +++ b/requirements-testing.txt @@ -12,7 +12,6 @@ asttokens responses pysocks socksio -httpcore[http2] setuptools Brotli docker diff --git a/scripts/populate_tox/config.py b/scripts/populate_tox/config.py index 317afa53ca..a8b9174b24 100644 --- a/scripts/populate_tox/config.py +++ b/scripts/populate_tox/config.py @@ -108,8 +108,8 @@ "djangorestframework", "pytest-django", "Werkzeug", + "channels[daphne]", ], - ">=2.0": ["channels[daphne]"], ">=2.2,<3.1": ["six"], ">=3.0": ["pytest-asyncio"], "<3.3": [ @@ -117,6 +117,7 @@ "Werkzeug<2.1.0", ], "<3.1": ["pytest-django<4.0"], + "py3.6": ["dataclasses"], "py3.14,py3.14t": ["coverage==7.11.0"], }, }, @@ -162,6 +163,7 @@ "itsdangerous>=0.24,<2.0", "jinja2<3.1.1", ], + "py3.6": ["dataclasses"], }, }, "gql": { @@ -512,6 +514,7 @@ "deps": { "*": ["werkzeug"], "<=5.0": ["werkzeug<1.0"], + "py3.6": ["dataclasses"], }, }, "typer": { diff --git a/scripts/populate_tox/tox.jinja b/scripts/populate_tox/tox.jinja index 40426d30fb..d3d88dbb48 100644 --- a/scripts/populate_tox/tox.jinja +++ b/scripts/populate_tox/tox.jinja @@ -78,9 +78,10 @@ deps = -r requirements-testing.txt # === Common === + py3.6-common: dataclasses py3.8-common: hypothesis common: pytest-asyncio - common: httpcore[asyncio] + common: httpcore[asyncio,http2] # See https://github.com/pytest-dev/pytest/issues/9621 # and https://github.com/pytest-dev/pytest-forked/issues/67 # for justification of the upper bound on pytest @@ -90,6 +91,7 @@ deps = {py3.14,py3.14t}-common: coverage==7.11.0 # === Gevent === + py3.6-gevent: dataclasses {py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}-gevent: gevent>=22.10.0, <22.11.0 {py3.12}-gevent: gevent # See https://github.com/pytest-dev/pytest/issues/9621 @@ -97,6 +99,7 @@ deps = # for justification of the upper bound on pytest {py3.6,py3.7}-gevent: pytest<7.0.0 {py3.8,py3.9,py3.10,py3.11,py3.12}-gevent: pytest + gevent: httpcore[http2] gevent: pytest-asyncio gevent: setuptools<82 {py3.10,py3.11}-gevent: zope.event<5.0.0 diff --git a/sentry_sdk/utils.py b/sentry_sdk/utils.py index 875d28c0d0..f6d9b66b9c 100644 --- a/sentry_sdk/utils.py +++ b/sentry_sdk/utils.py @@ -1,5 +1,4 @@ import base64 -import contextvars import copy import json import linecache @@ -84,28 +83,6 @@ _installed_modules = None -_is_sentry_internal_task = contextvars.ContextVar( - "is_sentry_internal_task", default=False -) - -# These exceptions won't set the span status to error if they occur. Use -# register_control_flow_exception to add to this list -_control_flow_exception_classes: "set[type]" = set() - - -def is_internal_task() -> bool: - return _is_sentry_internal_task.get() - - -@contextmanager -def mark_sentry_task_internal() -> "Generator[None, None, None]": - """Context manager to mark a task as Sentry internal.""" - token = _is_sentry_internal_task.set(True) - try: - yield - finally: - _is_sentry_internal_task.reset(token) - BASE64_ALPHABET = re.compile(r"^[a-zA-Z0-9/+=]*$") @@ -1468,6 +1445,26 @@ def _get_contextvars() -> "Tuple[bool, type]": Please refer to https://docs.sentry.io/platforms/python/contextvars/ for more information. """ +_is_sentry_internal_task = ContextVar("is_sentry_internal_task", default=False) + +# These exceptions won't set the span status to error if they occur. Use +# register_control_flow_exception to add to this list +_control_flow_exception_classes: "set[type]" = set() + + +def is_internal_task() -> bool: + return _is_sentry_internal_task.get() + + +@contextmanager +def mark_sentry_task_internal() -> "Generator[None, None, None]": + """Context manager to mark a task as Sentry internal.""" + token = _is_sentry_internal_task.set(True) + try: + yield + finally: + _is_sentry_internal_task.reset(token) + def qualname_from_function(func: "Callable[..., Any]") -> "Optional[str]": """Return the qualified name of func. Works with regular function, lambda, partial and partialmethod.""" diff --git a/tox.ini b/tox.ini index e91115d32e..30d608ff56 100644 --- a/tox.ini +++ b/tox.ini @@ -401,9 +401,10 @@ deps = -r requirements-testing.txt # === Common === + py3.6-common: dataclasses py3.8-common: hypothesis common: pytest-asyncio - common: httpcore[asyncio] + common: httpcore[asyncio,http2] # See https://github.com/pytest-dev/pytest/issues/9621 # and https://github.com/pytest-dev/pytest-forked/issues/67 # for justification of the upper bound on pytest @@ -413,6 +414,7 @@ deps = {py3.14,py3.14t}-common: coverage==7.11.0 # === Gevent === + py3.6-gevent: dataclasses {py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}-gevent: gevent>=22.10.0, <22.11.0 {py3.12}-gevent: gevent # See https://github.com/pytest-dev/pytest/issues/9621 @@ -420,6 +422,7 @@ deps = # for justification of the upper bound on pytest {py3.6,py3.7}-gevent: pytest<7.0.0 {py3.8,py3.9,py3.10,py3.11,py3.12}-gevent: pytest + gevent: httpcore[http2] gevent: pytest-asyncio gevent: setuptools<82 {py3.10,py3.11}-gevent: zope.event<5.0.0 @@ -12179,7 +12182,6 @@ deps = django-latest: django==6.0.6 - django-latest: channels[daphne] django-latest: pytest-asyncio py3.12-django-latest: asgiref==3.11.1 @@ -12198,12 +12200,7 @@ deps = django: djangorestframework django: pytest-django django: Werkzeug - django-v2.2.28: channels[daphne] - django-v3.2.25: channels[daphne] - django-v4.2.30: channels[daphne] - django-v5.2.15: channels[daphne] - django-v6.0.6: channels[daphne] - django-v6.1a1: channels[daphne] + django: channels[daphne] django-v2.2.28: six django-v3.2.25: pytest-asyncio django-v4.2.30: pytest-asyncio @@ -12218,8 +12215,8 @@ deps = django-v3.2.25: Werkzeug<2.1.0 django-v1.11.29: pytest-django<4.0 django-v2.2.28: pytest-django<4.0 + {py3.6}-django: dataclasses {py3.14,py3.14t}-django: coverage==7.11.0 - django-latest: channels[daphne] django-latest: pytest-asyncio flask-v1.1.4: flask==1.1.4 @@ -12333,6 +12330,7 @@ deps = flask-v1.1.4: markupsafe<2.0.0 flask-v1.1.4: itsdangerous>=0.24,<2.0 flask-v1.1.4: jinja2<3.1.1 + {py3.6}-flask: dataclasses starlette-v0.16.0: starlette==0.16.0 @@ -14132,6 +14130,7 @@ deps = trytond: werkzeug trytond-v4.6.22: werkzeug<1.0 trytond-v4.8.18: werkzeug<1.0 + {py3.6}-trytond: dataclasses typer-v0.15.4: typer==0.15.4