| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
This ensures that future whitebox internal test changes do not regress the public surface semantics.
By using this state class and managing implicit and explicit batching, we make it structurally impossible to get bitten by re-entrant site startup processing. Fixes python#149504 Update all the implementation and integration tests.
|
I'll try to take a look if you want more reviews but I don't really know site.py. Thanks for working on this! |
Sorry, something went wrong.
That's okay. I just tagged you to check that the uv case works with this branch, but @zsol confirmed it fixed the problem (thanks!). |
Sorry, something went wrong.
|
Thanks @warsaw for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15. |
Sorry, something went wrong.
|
Sorry, @warsaw, I could not cleanly backport this to 3.15 due to a conflict. cherry_picker b162307d7f216e87976d76c9b8f4a932961cb2d4 3.15 |
Sorry, something went wrong.
|
GH-149799 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
…ite.add sitedir() (#149659) (#149799) * gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.addsitedir() (#149659) * Add re-entrant tests for gh-149504 * Add end-to-end integration test coverage This ensures that future whitebox internal test changes do not regress the public surface semantics. * Implement a state class to process .pth and .start files By using this state class and managing implicit and explicit batching, we make it structurally impossible to get bitten by re-entrant site startup processing. Fixes #149504 (cherry picked from commit b162307) * Add myself back to CODEOWNERS
| Back | FazBrowse Home | New Git URL |
Fix site.addsitedir() to allow re-entrant calls from within startup files. Previously, a .pth file containing an import line that called site.addsitedir() (or a .start entry point doing the same) could crash with RuntimeError: dictionary changed size during iteration during site initialization, breaking tools such as uv run --with.
mkdir -p /tmp/site-repro/root /tmp/site-repro/overlay printf 'import site; site.addsitedir("/tmp/site-repro/overlay")\n' > /tmp/site-repro/root/reenter.pth ./python.exe -S -c 'import site; site.addsitedir("/tmp/site-repro/root"); print("done")'prints "done" for me.
does not crash.
The implementation is more comprehensive than #149516 and is more inline with a suggestion @ncoghlan made on the original PR. Thanks @zsol for providing your PR. @JelleZijlstra please take a look.