[3.15] gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.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 b162307d7f)

* Add myself back to CODEOWNERS
This commit is contained in:
Barry Warsaw 2026-05-13 15:45:39 -07:00 committed by GitHub
parent b6503057b2
commit 45fc9acb8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 746 additions and 416 deletions

6
.github/CODEOWNERS vendored
View file

@ -573,9 +573,9 @@ Lib/shutil.py @giampaolo
Lib/test/test_shutil.py @giampaolo
# Site
Lib/site.py @FFY00
Lib/test/test_site.py @FFY00
Doc/library/site.rst @FFY00
Lib/site.py @FFY00 @warsaw
Lib/test/test_site.py @FFY00 @warsaw
Doc/library/site.rst @FFY00 @warsaw
# string.templatelib
Doc/library/string.templatelib.rst @lysnikolaou @AA-Turner