Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
It turns out this is not true:
pybind11/tests/test_embed/test_interpreter.cpp
Lines 206 to 207 in b14d58b
I stumbled over this when testing locally with Python 3.10.8. Because I had the problem locally (vs CI failures as we saw under #4330) it was easy to debug. I added
printf()
s forrepr(sys.path)
to test_interpreter.cpp, then used the output like this:Output:
Evidently the pre-PyConfig behavior is not identical to the behavior with a default
PyConfig
: the site-packages directory is handled differently. — Such a difference is not really surprising, in hindsight.Side note: Even when completely removing this code
pybind11/tests/test_embed/test_interpreter.cpp
Lines 220 to 223 in b14d58b
the test right below failed, disproving the comment quoted above without a doubt.
The problem with the test really is that it compares apples and oranges.
The fix is to isolate the test from the pre-PyConfig/PyConfig behavior differences by computing the
len(sys.path)
under exactly identical conditions, except for theadd_program_dir_to_path
false
/true
difference.Suggested changelog entry: