Claim that to exceed 32KB the path needs to be so long that it's fine to fail in that case, and close the issue as unplanned. (while I acknowledge this requires quite a long path to hit in practice, I did run into this in our CI system at Meta, so it's not totally hypothetical)
Decrease the number of repetitions in test_site (e.g. from 200 to 20) to raise the threshold for the path length that would trigger this failure (this fixes it for me internally). I don't know what's the significance of the number of repetitions in these tests, and why 200 was chosen specifically.
Keep it at 200 repetitions, but add a check in the tests that if the generated _pth file exceeds 32KB, the test skips itself (e.g. raise some resource denied).
Some mix of 2 & 3 -- make the _pth generation "adaptive" - start with 200, but as long as the file exceeds 32KB try fewer repetitions (e.g. 100, 50, 20), and skip the test if even the fewest number of repetitions exceeds 32KB.
I'm happy to submit a PR for any of the 2-4 options.
A test that fails with a legal stdlib path over about 160 (2**15//200 rounded down) chars is broken. I would replace 200 with min(200, 30000 // len(libpath)).
Activity
itamaro commented on Jan 1, 2024
A few ways to go about this:
I'm happy to submit a PR for any of the 2-4 options.
terryjreedy commented on Jan 1, 2024
A test that fails with a legal stdlib path over about 160 (2**15//200 rounded down) chars is broken. I would replace 200 with min(200, 30000 // len(libpath)).
fix pythongh-113628: reduce number of libpath lines in pth lines to a…
gh-113628: Fix test_site test with long stdlib paths (#113640)
pythongh-113628: Fix test_site test with long stdlib paths (pythonGH-…
pythongh-113628: Fix test_site test with long stdlib paths (pythonGH-…
[3.12] gh-113628: Fix test_site test with long stdlib paths (GH-113640)…
[3.11] gh-113628: Fix test_site test with long stdlib paths (GH-113640)…
Backport gh-113628: Fix test_site test with long stdlib paths
pythongh-113628: Fix test_site test with long stdlib paths (python#11…
pythongh-113628: Fix test_site test with long stdlib paths (python#11…
pythongh-113628: Fix test_site test with long stdlib paths (python#11…