🧪 test(conftest): strip broken nspkg.pth files under py3.15#3937
Open
gaborbernat wants to merge 1 commit into
Open
🧪 test(conftest): strip broken nspkg.pth files under py3.15#3937gaborbernat wants to merge 1 commit into
gaborbernat wants to merge 1 commit into
Conversation
PasteDeploy and repoze.lru, pulled in transitively by devpi-server, install legacy setuptools nspkg.pth files that read sys._getframe(1).f_locals['sitedir']. Python 3.13 rewrote site.py as a frozen module and that local no longer exists, so every interpreter spawn emits a KeyError to stderr. Six tests across local_subprocess and parallel suites assert on exact subprocess stderr and fail under 3.15. Removing the offending pth files at conftest import is the smallest surgical fix: the paste and repoze namespaces still resolve via PEP 420 implicit packages, so devpi-server keeps working, and the cleanup is idempotent under xdist.
This was referenced May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Six tests in the local subprocess and parallel suites fail on the weekly Python 3.15 check (run 25667044284) because every spawned interpreter prints a
KeyErrorto stderr before user code runs, and the assertions compare stderr byte-for-byte.The noise originates in the legacy
*-nspkg.pthfiles shipped byPasteDeploy 3.1.0andrepoze.lru 0.7, both pulled in transitively bydevpi-server→pyramid. Those pth files callsys._getframe(1).f_locals['sitedir'], which worked whensite.pywalked its own frame. PEP 829 (CPython #149109) replaced that machinery with a deferred_exec_imports()that has nositedirlocal, so every interpreter startup raisesKeyError: "local variable ''sitedir'' is not defined". The regression is tracked upstream in CPython #149671.This is genuinely an upstream problem: the proper fix lives either in CPython (restoring compatibility with legacy
.pthhacks, or providing a migration path) or insetuptools(which still generates these pth files fornamespace_packages=declarations even thoughpkg_resourceswas removed in 82.0.0). Thepasteandrepozenamespaces would still resolve via PEP 420 without the.pthshim, so the affected packages could also dropnamespace_packages=upstream.Until any of those land, this patch removes the offending pth files at conftest import — gated by the broken
f_locals['sitedir']substring so unrelated namespace pth files are untouched, and wrapped incontextlib.suppress(OSError)to stay idempotent underxdistworkers racing on the same file. Revert once the upstream fix is available.