chore(wrapping): run wrap() trampoline on Python 3.15 (PROF-15852) - #19910
Conversation
Codeowners resolved asResolved from the full PR diff against No remaining files require a CODEOWNERS review. |
Dependency direction analysis
|
Circular import analysis
|
🎉 All green!🧪 All tests passed 🔗 Commit SHA: c4b6422 | Docs | View more details | Give us feedback! |
7e34962 to
612f5d6
Compare
0af858e to
026ce58
Compare
BenchmarksBenchmark execution time: 2026-08-28 15:20:03 Comparing candidate commit c4b6422 in PR branch Found 0 performance improvements and 6 performance regressions! Performance is the same for 576 metrics, 10 unstable metrics, 2 known flaky benchmarks, 16 flaky benchmarks without significant changes.
|
612f5d6 to
7e34962
Compare
026ce58 to
0af858e
Compare
There was a problem hiding this comment.
Pull request overview
This PR enables ddtrace.internal.wrapping.wrap() / wrap_bytecode() to execute on Python 3.15 (instead of raising NotImplementedError), relying on the existing trampoline logic and newly-added 3.15 generator/coroutine assemblies from the stacked work. It updates the Python 3.15 “import-time degrade” tests accordingly and adjusts the inject_hook() expectation to match the 3.15 sys.monitoring implementation.
Changes:
- Remove the Python “next-unsupported” guard that raised
NotImplementedErrorinwrap()/wrap_bytecode(). - Replace the 3.15 “wrap raises” test with sync/generator/coroutine wrap exercises.
- Update the 3.15
inject_hook()test to no longer expectNotImplementedErrorand to use an executable line number.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/internal/test_py315_import_degrade.py |
Updates 3.15 degrade tests to exercise wrap behavior (sync/generator/coroutine) and adjusts inject_hook() expectations for 3.15. |
ddtrace/internal/wrapping/__init__.py |
Removes the explicit 3.15+ NotImplementedError gate so wrapping code paths run on 3.15. |
Suppressed comments (1)
tests/internal/test_py315_import_degrade.py:125
- This test now only checks that inject_hook() doesn’t raise, but it doesn’t verify that the hook is actually invoked when the function runs on 3.15+ (sys.monitoring path). Adding a call and an assertion would prevent regressions where registration succeeds but the hook never fires.
@pytest.mark.skipif(PYTHON_VERSION_INFO < NEXT_PY_VERSION_INFO, reason=f"{NEXT_PY_VERSION} debugging products degrade")
def test_debugging_products_load_without_failure():
from ddtrace.internal.products import ProductManager
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
Suppressed comments (1)
tests/internal/test_py315_import_degrade.py:59
- Same as the sync wrap test: the current skip condition allows this coroutine test to run on Python 3.16+ where wrap() should raise NotImplementedError, causing unexpected failures when the test matrix advances.
@pytest.mark.skipif(PYTHON_VERSION_INFO < NEXT_PY_VERSION_INFO, reason=f"{NEXT_PY_VERSION} wrap() coroutine")
@pytest.mark.asyncio
async def test_wrap_coroutine_on_315():
**prev:** [#19906](#19906) | **next:** [#19910](#19910) ## Summary Wrapping context + bytecode injection for 3.15. Delta vs #19906 only (monitoring + 3.15 assemblies). ## Test plan - [ ] CI green on this branch - [ ] Stack merges cleanly into the next PR's base branch Co-authored-by: vlad-scherbich <vlad.scherbich@datadoghq.com> Co-authored-by: gabriele.tornetta <gabriele.tornetta@datadoghq.com>
wrap() already gates on NEXT_PY_VERSION_INFO. Lifting the constant enables the 3.15 trampoline and fail-closes on 3.16, so the adhoc +1 tripwire can go.
f37dfc2 to
c4b6422
Compare
NEXT_MAX_PY is 3.15 (packaging). wrap() and lazy must match merged #19910: trampoline and WrappingContext are live on 3.15, fail closed from 3.16. A rebase onto main must not re-disable wrap on 3.15.
Description
#17849 is on main: 3.15 generator/coroutine assemblies and sys.monitoring WrappingContext / inject_hook. wrap() / wrap_bytecode() still gate on
NEXT_PY_VERSION_INFO(was 3.15), so they raised on 3.15.This PR sets
NEXT_PY_VERSIONto 3.16. The wrap() comparison is unchanged, so wrap() runs the existing trampoline on 3.15 and fail-closes from 3.16. Not a sys.monitoring port of wrap().requires-pythonstays>=3.9,<3.15.Side effect:
@lazyon 3.15 takes thePYTHON_VERSION_INFO < NEXTbranch (LazyWrappingContext.wrap()). inject_hook is already monitoring-based on 3.15 (PY >= (3, 15)); this PR does not change that gate.Testing
Sync, generator, and coroutine trampoline tests pinned to 3.15 (
>= (3, 15)and< NEXT_PY). A monkeypatch pins fail-closed from 3.16.Risks
3.15 is still unsupported (
requires-python <3.15).Additional Notes
Part of #17810. No release note: internal wrapping, 3.15 unsupported;
changelog/no-changelog.