FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-148641: Implement PEP 829 - startup configuration files by warsaw · Pull Request #149109 · python/cpython · GitHub

Repository navigation

gh-148641: Implement PEP 829 - startup configuration files - #149109

Merged
warsaw merged 58 commits into
python:mainfrom
warsaw:warsaw/829
May 3, 2026
Merged

warsaw merged 58 commits into
python:mainfrom
warsaw:warsaw/829

Conversation

warsaw commented Apr 28, 2026 •
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

warsaw added 23 commits March 31, 2026 17:13
It's okay to be missing, but if it's given it must be an expected
version (i.e. currently, 1).
* Add _print_error() helper function for printing exceptions to sys.stderr.  These are not hidden
  behind -v
* `warnings` can be lazy imported.
* Since the site.toml file is no longer proposed, rewrite how .pth and .start files are parsed and
  processed.
* addpackage() -- which was never documented -- is deprecated; there are a few usages in the wild so
  we can't get rid of it, but it's generally unnecessary now, has different semantics.
* Update tests

read-the-docs-community Bot commented Apr 28, 2026 •
edited
Loading

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32516357 | 📁 Comparing 5019131 against main (2b6a137)

  🔍 Preview build  

54 files changed · ± 54 modified

± Modified

warsaw added 5 commits May 2, 2026 10:29
* flush_pth_start() -> process_startup_files()
* Move around some versionchanged and deprecated-removed sections
* Add: kw-only arg `defer_processing_start_files` in several places to ensure that the
  reverse-engineered semantics of the undocumented functions are preserved.

warsaw commented May 3, 2026

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

@ncoghlan

bedevere-app Bot commented May 3, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@brettcannon, @ncoghlan: please review the changes made to this pull request.

bedevere-app Bot requested a review from ncoghlan May 3, 2026 02:15

warsaw commented May 3, 2026 via email

Copy link
Copy Markdown
Member Author

ncoghlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @warsaw, this iteration looks good for 3.15b1 to me (one minor parameter naming nitpick, but it's in an API detail I'd like to revisit in more depth for 3.15b2 anyway, hence I don't think it's a merge blocker)

Comment thread Doc/library/site.rst
warsaw enabled auto-merge (squash) May 3, 2026 16:51
warsaw dismissed brettcannon’s stale review May 3, 2026 16:51

Got approval from @NCoughlan

warsaw commented May 3, 2026 •
edited
Loading

Copy link
Copy Markdown
Member Author

Argh! Sorry for the typo in the review dismissal. GH doesn't actually autocomplete in that dialog and it can't be edited. Approval was received from @ncoghlan

warsaw merged commit 24c4aec into python:main May 3, 2026
51 checks passed
warsaw deleted the warsaw/829 branch May 3, 2026 17:21
gaborbernat added a commit to tox-dev/tox that referenced this pull request May 12, 2026
Six tests in the local subprocess and parallel suites fail on the weekly
Python 3.15 check (run
[25667044284](https://github.com/tox-dev/tox/actions/runs/25667044284))
because every spawned interpreter prints a `KeyError` to stderr before
user code runs, and the assertions compare stderr byte-for-byte.

The noise originates in the legacy `*-nspkg.pth` files shipped by
`PasteDeploy 3.1.0` and `repoze.lru 0.7`, both pulled in transitively by
`devpi-server` → `pyramid`. Those pth files call
`sys._getframe(1).f_locals['sitedir']`, which worked when `site.py`
walked its own frame. PEP 829 (CPython
[#149109](python/cpython#149109)) replaced that
machinery with a deferred `_exec_imports()` that has no `sitedir` local,
so every interpreter startup raises `KeyError: "local variable
''sitedir'' is not defined"`. The regression is tracked upstream in
CPython [#149671](python/cpython#149671).

This is genuinely an upstream problem: the proper fix lives either in
CPython (restoring compatibility with legacy `.pth` hacks, or providing
a migration path) or in `setuptools` (which still generates these pth
files for `namespace_packages=` declarations even though `pkg_resources`
was removed in 82.0.0). The `paste` and `repoze` namespaces would still
resolve via PEP 420 without the `.pth` shim, so the affected packages
could also drop `namespace_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 in
`contextlib.suppress(OSError)` to stay idempotent under `xdist` workers
racing on the same file. Revert once the upstream fix is available.
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL