Skip to content
Open
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
5 changes: 3 additions & 2 deletions .gitlab/scripts/prune-unsupported-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ set -euo pipefail
#
# TODO(py-315): cp315 wheels are built by "build linux" and "build linux serverless" under
# allow_failure so that 3.15 keeps producing CI signal, but they are compiled against the
# 3.15.0b1 PyThreadState layout and are ABI-broken. Drop cp315 from this list once #19861
# makes those wheels correct and 3.15 is a supported target.
# 3.15.0b1 PyThreadState layout and are ABI-broken. #19861 does not fix that ABI; it only
# makes cp315 optional in the package validator. Drop cp315 from this list after IMAGE_TAG
# is on images that can build a correct wheel, and only once 3.15 is a supported target.
UNSUPPORTED_TAGS=("cp315")

if [ "$#" -eq 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/internal/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
NEXT_PY_VERSION: str = "3.15"
_next_py_parts = NEXT_PY_VERSION.split(".")[:2]
NEXT_PY_VERSION_INFO: tuple[int, int] = (int(_next_py_parts[0]), int(_next_py_parts[1]))
NEXT_PY_UNSUPPORTED_MSG: str = "This version of CPython is not supported yet (Python %s and later)" % NEXT_PY_VERSION
NEXT_PY_UNSUPPORTED_MSG: str = "This version of CPython is not supported yet: {}.{}".format(*sys.version_info[:2])


def ensure_text(s, encoding="utf-8", errors="ignore") -> str:
Expand Down
45 changes: 13 additions & 32 deletions tests/internal/test_py315_import_degrade.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
"""Python 3.15 import-time degrade: wrapping must load, wrap() still raises.
"""Python 3.15 import-time degrade: wrapping must load.

Until #17849 lands bytecode wrapping for 3.15, products that import wrapping
(e.g. ModuleWatchdog) must not crash the process. wrap()/inject_hook still
raise NotImplementedError when actually used.
Products that import wrapping (e.g. ModuleWatchdog) must not crash the process.
Monitoring ``inject_hook`` already works on 3.15; this module does not assert
that wrap() raises. Wrap lift is a later PR.
"""

import pytest

from ddtrace.internal.compat import NEXT_PY_UNSUPPORTED_MSG
from ddtrace.internal.compat import NEXT_PY_VERSION
from ddtrace.internal.compat import NEXT_PY_VERSION_INFO
from ddtrace.internal.compat import PYTHON_VERSION_INFO


_RUNNING_VERSION = f"{PYTHON_VERSION_INFO[0]}.{PYTHON_VERSION_INFO[1]}"
_UNSUPPORTED_MSG = f"This version of CPython is not supported yet: {_RUNNING_VERSION}"


def test_unsupported_msg_includes_running_version():
assert NEXT_PY_UNSUPPORTED_MSG == _UNSUPPORTED_MSG


def test_wrapping_modules_import():
import ddtrace.internal.bytecode_injection # noqa: F401
import ddtrace.internal.module # noqa: F401
Expand All @@ -20,20 +29,6 @@ def test_wrapping_modules_import():
import ddtrace.internal.wrapping.generators # noqa: F401


@pytest.mark.skipif(PYTHON_VERSION_INFO < NEXT_PY_VERSION_INFO, reason=f"{NEXT_PY_VERSION} wrap() degrade")
def test_wrap_raises_not_implemented_on_315():
from ddtrace.internal.wrapping import wrap

def f() -> None:
return None

def wrapper(wrapped, args, kwargs): # noqa: ANN001, ANN202
return wrapped(*args, **kwargs)

with pytest.raises(NotImplementedError, match="3.15"):
wrap(f, wrapper)


@pytest.mark.skipif(PYTHON_VERSION_INFO < NEXT_PY_VERSION_INFO, reason=f"{NEXT_PY_VERSION} lazy module degrade")
def test_lazy_module_decorator_without_bytecode_wrap():
import tests.internal.lazy as lazy_module
Expand Down Expand Up @@ -64,17 +59,3 @@ def test_debugging_products_load_without_failure():
"live-debugger",
):
assert product_name not in product_manager._failed


@pytest.mark.skipif(PYTHON_VERSION_INFO < NEXT_PY_VERSION_INFO, reason=f"{NEXT_PY_VERSION} inject_hook degrade")
def test_inject_hook_raises_not_implemented_on_315():
from ddtrace.internal.bytecode_injection import inject_hook

def f() -> None:
return None

def hook(_arg: object) -> None:
return None

with pytest.raises(NotImplementedError, match="3.15"):
inject_hook(f, hook, f.__code__.co_firstlineno, None)
Loading