Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ format: .venv
.PHONY: format

test: .venv
@$(VENV_PATH)/bin/tox -e py3.9
@$(VENV_PATH)/bin/tox -e py3.12
.PHONY: test

test-all: .venv
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_aws_lambda_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def install_python_packages(self):

sentry_python_sdk = os.path.join(
DIST_PATH,
f"sentry_sdk-{SDK_VERSION}-py2.py3-none-any.whl", # this is generated by "make dist" that is called by "make aws-lamber-layer"
f"sentry_sdk-{SDK_VERSION}-py2.py3-none-any.whl", # this is generated by "make dist" that is called by "make aws-lambda-layer"
)
subprocess.run(
[
Expand Down
10 changes: 2 additions & 8 deletions scripts/init_serverless_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,15 @@ def extract_and_load_lambda_function_module(self, module_path):
module_name = module_path.split(os.path.sep)[-1]
module_file_path = module_path + ".py"

# Supported python versions are 2.7, 3.6, 3.7, 3.8
if py_version >= (3, 5):
# Supported python versions are 3.6, 3.7, 3.8
if py_version >= (3, 6):
import importlib.util

spec = importlib.util.spec_from_file_location(
module_name, module_file_path
)
self.lambda_function_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(self.lambda_function_module)
elif py_version[0] < 3:
import imp

self.lambda_function_module = imp.load_source(
module_name, module_file_path
)
else:
raise ValueError("Python version %s is not supported." % py_version)
else:
Expand Down
14 changes: 4 additions & 10 deletions sentry_sdk/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,10 @@ def __exit__(self, exc_type, exc_value, tb):

def _check_python_deprecations():
# type: () -> None
version = sys.version_info[:2]

if version == (3, 4) or version == (3, 5):
logger.warning(
"sentry-sdk 2.0.0 will drop support for Python %s.",
"{}.{}".format(*version),
)
logger.warning(
"Please upgrade to the latest version to continue receiving upgrades and bugfixes."
)
# Since we're likely to deprecate Python versions in the future, I'm keeping
# this handy function around. Use this to detect the Python version used and
# to output logger.warning()s if it's deprecated.
pass


def _init(*args, **kwargs):
Expand Down
4 changes: 1 addition & 3 deletions sentry_sdk/integrations/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def setup_once():
)
return

pre_37 = hasattr(lambda_bootstrap, "handle_http_request") # Python 3.6 or 2.7
pre_37 = hasattr(lambda_bootstrap, "handle_http_request") # Python 3.6

if pre_37:
old_handle_event_request = lambda_bootstrap.handle_event_request
Expand Down Expand Up @@ -286,8 +286,6 @@ def inner(*args, **kwargs):
def get_lambda_bootstrap():
# type: () -> Optional[Any]

# Python 2.7: Everything is in `__main__`.
#
# Python 3.7: If the bootstrap module is *already imported*, it is the
# one we actually want to use (no idea what's in __main__)
#
Expand Down
10 changes: 2 additions & 8 deletions sentry_sdk/integrations/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
"import_string_should_wrap_middleware"
)

if DJANGO_VERSION < (1, 7):
import_string_name = "import_by_path"
else:
import_string_name = "import_string"


if DJANGO_VERSION < (3, 1):
_asgi_middleware_mixin_factory = lambda _: object
else:
Expand All @@ -44,7 +38,7 @@ def patch_django_middlewares():
# type: () -> None
from django.core.handlers import base

old_import_string = getattr(base, import_string_name)
old_import_string = base.import_string

def sentry_patched_import_string(dotted_path):
# type: (str) -> Any
Expand All @@ -55,7 +49,7 @@ def sentry_patched_import_string(dotted_path):

return rv

setattr(base, import_string_name, sentry_patched_import_string)
base.import_string = sentry_patched_import_string

old_load_middleware = base.BaseHandler.load_middleware

Expand Down
16 changes: 5 additions & 11 deletions sentry_sdk/integrations/stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import subprocess
import sys
import platform
from sentry_sdk.consts import OP, SPANDATA
from http.client import HTTPConnection

from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.hub import Hub
from sentry_sdk.integrations import Integration
from sentry_sdk.scope import add_global_event_processor
Expand All @@ -16,7 +17,6 @@
safe_repr,
parse_url,
)

from sentry_sdk._types import TYPE_CHECKING

if TYPE_CHECKING:
Expand All @@ -29,12 +29,6 @@
from sentry_sdk._types import Event, Hint


try:
from httplib import HTTPConnection # type: ignore
except ImportError:
from http.client import HTTPConnection


_RUNTIME_CONTEXT = {
"name": platform.python_implementation(),
"version": "%s.%s.%s" % (sys.version_info[:3]),
Expand Down Expand Up @@ -114,7 +108,7 @@ def putrequest(self, method, url, *args, **kwargs):
)
self.putheader(key, value)

self._sentrysdk_span = span
self._sentrysdk_span = span # type: ignore[attr-defined]

return rv

Expand All @@ -133,8 +127,8 @@ def getresponse(self, *args, **kwargs):

return rv

HTTPConnection.putrequest = putrequest
HTTPConnection.getresponse = getresponse
HTTPConnection.putrequest = putrequest # type: ignore[method-assign]
HTTPConnection.getresponse = getresponse # type: ignore[method-assign]


def _init_argument(args, kwargs, name, position, setdefault_callback=None):
Expand Down