Skip to content

fix(bootstrap): do not unload yaml/_yaml during module cleanup [backport 3.12] - #19063

Closed
juanjux wants to merge 2 commits into
3.12from
juanjux/backport-18927-to-3.12
Closed

juanjux wants to merge 2 commits into
3.12from
juanjux/backport-18927-to-3.12

Conversation

@juanjux

@juanjux juanjux commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Description

Backports #18927 to 3.12. Keeps yaml and _yaml loaded during module cleanup so consumers with cached PyYAML loader references remain valid.

The internal Riot requirements were regenerated on the 3.12 branch to include PyYAML without carrying over conflicting lockfile hashes from main. This legacy branch still performs cleanup in sitecustomize.py, so the fix and regression test were adapted to that architecture.

Testing

  • scripts/ddtest riot -v run --pass-env 1b68e85 -- tests/internal/test_auto.py::test_yaml_not_unloaded
  • scripts/lint riot
  • Targeted formatting checks passed

Risks

Low. The change retains the PyYAML modules during bootstrap cleanup.

Additional Notes

Manual backport of #18927 after adapting the change to the older bootstrap implementation and resolving Riot lockfile conflicts.

Keep yaml and _yaml loaded so consumers that cache PyYAML loaders do not retain stale references after module cleanup. Regenerate the legacy internal test locks with compatible setuptools requirements.

(cherry picked from commit 05644ea)
@juanjux
juanjux requested review from a team as code owners July 15, 2026 11:03
@juanjux
juanjux requested review from brettlangdon and mabdinur and removed request for a team July 15, 2026 11:03
@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

.riot/requirements/134898f.txt                                          @DataDog/apm-python
.riot/requirements/17d4d4e.txt                                          @DataDog/apm-python
.riot/requirements/1b68e85.txt                                          @DataDog/apm-python
.riot/requirements/1ebd71c.txt                                          @DataDog/apm-python
.riot/requirements/fe44e64.txt                                          @DataDog/apm-python
releasenotes/notes/fix-cloning-unload-yaml-9c6899a662eed44c.yaml        @DataDog/apm-python
ddtrace/bootstrap/sitecustomize.py                                      @DataDog/apm-core-python
riotfile.py                                                             @DataDog/apm-python
tests/internal/test_auto.py                                             @DataDog/apm-core-python
.riot/requirements/1339226.txt                                          @DataDog/apm-python

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests

✨ Fix all issues with BitsAI

⚠️ Warnings

🚦 78 Pipeline jobs failed

Build | Build source distribution   View in Datadog   GitHub Actions

Build | build_wheels / Build cp310-macosx_arm64   View in Datadog   GitHub Actions

Build | build_wheels / Build cp310-manylinux_aarch64   View in Datadog   GitHub Actions

View all 78 failed jobs.

ℹ️ Info

🔄 Datadog auto-retried 2 jobs - 0 passed on retry View in Datadog

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5554b29 | Docs | Datadog PR Page | Give us feedback!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14fc3c11b3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .riot/requirements/1bb266a.txt Outdated
zope-interface==8.0.1

# The following packages are considered to be unsafe in a requirements file:
setuptools==82.0.1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep setuptools below 82 in the Python 3.9 lock

When the internal Riot environment runs on Python 3.9, this new lockfile installs setuptools==82.0.1, while the suite still imports pkg_resources directly, for example in tests/internal/test_packages.py:36. The riotfile comment pins <82 only for the Python >=3.12 child because pkg_resources was removed there, so the Python 3.9 internal job using this lock will fail before running the intended regression test; apply the same constraint to the 3.8-3.11 child or regenerate this lock without setuptools 82.

Useful? React with 👍 / 👎.

Keep setuptools below 82 across Python 3.8 through 3.11 so legacy internal tests can continue importing pkg_resources.
@juanjux

juanjux commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator Author

The circular-import failure is pre-existing on the 3.12 branch and is addressed separately by #19064 (backport of #19030). Merge #19064 first, then rerun this PR against the updated 3.12 base.

@mabdinur

Copy link
Copy Markdown
Contributor

Do we need to backport this fix to 3.12? Should we backport to the last 3.x minor instead (ex: https://github.com/DataDog/dd-trace-py/tree/3.19)?

@juanjux juanjux closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants