diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index 690bdf5327..1602742a0c 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -252,7 +252,7 @@ def add_query_source(hub, span): except Exception: filepath = None if filepath is not None: - if namespace is not None and not PY2: + if namespace is not None: in_app_path = filename_for_module(namespace, filepath) elif project_root is not None and filepath.startswith(project_root): in_app_path = filepath.replace(project_root, "").lstrip(os.sep) diff --git a/tests/integrations/asyncpg/test_asyncpg.py b/tests/integrations/asyncpg/test_asyncpg.py index 6c2d142ef0..b0c6d9b30f 100644 --- a/tests/integrations/asyncpg/test_asyncpg.py +++ b/tests/integrations/asyncpg/test_asyncpg.py @@ -18,8 +18,6 @@ PG_HOST = os.getenv("SENTRY_PYTHON_TEST_POSTGRES_HOST", "localhost") PG_PORT = 5432 - -from sentry_sdk._compat import PY2 import datetime from contextlib import contextmanager from unittest import mock @@ -627,9 +625,8 @@ async def test_query_source_with_module_in_search_path(sentry_init, capture_even assert type(data.get(SPANDATA.CODE_LINENO)) == int assert data.get(SPANDATA.CODE_LINENO) > 0 - if not PY2: - assert data.get(SPANDATA.CODE_NAMESPACE) == "asyncpg_helpers.helpers" - assert data.get(SPANDATA.CODE_FILEPATH) == "asyncpg_helpers/helpers.py" + assert data.get(SPANDATA.CODE_NAMESPACE) == "asyncpg_helpers.helpers" + assert data.get(SPANDATA.CODE_FILEPATH) == "asyncpg_helpers/helpers.py" is_relative_path = data.get(SPANDATA.CODE_FILEPATH)[0] != os.sep assert is_relative_path diff --git a/tests/integrations/django/test_db_query_data.py b/tests/integrations/django/test_db_query_data.py index 7121f0c60d..878babf507 100644 --- a/tests/integrations/django/test_db_query_data.py +++ b/tests/integrations/django/test_db_query_data.py @@ -4,7 +4,6 @@ from datetime import datetime from unittest import mock -from sentry_sdk._compat import PY2 from django import VERSION as DJANGO_VERSION from django.db import connections @@ -205,10 +204,8 @@ def test_query_source_with_module_in_search_path(sentry_init, client, capture_ev assert type(data.get(SPANDATA.CODE_LINENO)) == int assert data.get(SPANDATA.CODE_LINENO) > 0 - - if not PY2: - assert data.get(SPANDATA.CODE_NAMESPACE) == "django_helpers.views" - assert data.get(SPANDATA.CODE_FILEPATH) == "django_helpers/views.py" + assert data.get(SPANDATA.CODE_NAMESPACE) == "django_helpers.views" + assert data.get(SPANDATA.CODE_FILEPATH) == "django_helpers/views.py" is_relative_path = data.get(SPANDATA.CODE_FILEPATH)[0] != os.sep assert is_relative_path diff --git a/tests/integrations/sqlalchemy/test_sqlalchemy.py b/tests/integrations/sqlalchemy/test_sqlalchemy.py index 6196583583..ce3d8bfec3 100644 --- a/tests/integrations/sqlalchemy/test_sqlalchemy.py +++ b/tests/integrations/sqlalchemy/test_sqlalchemy.py @@ -490,11 +490,8 @@ class Person(Base): assert type(data.get(SPANDATA.CODE_LINENO)) == int assert data.get(SPANDATA.CODE_LINENO) > 0 - if not PY2: - assert data.get(SPANDATA.CODE_NAMESPACE) == "sqlalchemy_helpers.helpers" - assert ( - data.get(SPANDATA.CODE_FILEPATH) == "sqlalchemy_helpers/helpers.py" - ) + assert data.get(SPANDATA.CODE_NAMESPACE) == "sqlalchemy_helpers.helpers" + assert data.get(SPANDATA.CODE_FILEPATH) == "sqlalchemy_helpers/helpers.py" is_relative_path = data.get(SPANDATA.CODE_FILEPATH)[0] != os.sep assert is_relative_path