GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-149671: Restore compatibility with setuptools nspkg.pth files in site module by vstinner · Pull Request #151319 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 11, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Inject "sitedir" variable in the frame which executes pth code.

  • Issue: PEP 829: KeyError: "local variable ''sitedir'' is not defined" #149671

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-149671: Restore compatibility with setuptools nspkg.pth file…
22d70ce
…s in site module

Inject "sitedir" variable in the frame which executes pth code.
@vstinner
vstinner requested a review from FFY00 as a code owner June 11, 2026 09:54
@vstinner vstinner added the needs backport to 3.15 bugs and security fixes label Jun 11, 2026
@vstinner
vstinner requested a review from warsaw as a code owner June 11, 2026 09:54
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 11, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jun 11, 2026
PEP 829: KeyError: "local variable ''sitedir'' is not defined" #149671
Closed
@vstinner
Remove unused variable
e21f879
vstinner
vstinner commented Jun 11, 2026
View reviewed changes
Comment thread Lib/site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@warsaw warsaw self-assigned this Jun 11, 2026
warsaw
warsaw requested changes Jun 11, 2026
View reviewed changes

@warsaw warsaw left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for putting this PR together @vstinner. As mentioned below, I think @encukou approach is slightly better, and I'm not opposed to adding it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_site.py Outdated

def test_sitedir_variable(self):
# gh-149671: Provide 'sitedir' local variable for compatibility with
# Python 3.14

@warsaw warsaw Jun 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
# Python 3.14
# setuptools use of `-nspkg.pth` files in Python < 3.15.

And please add a link to the setuptools issue where they are going to remove these .pth files.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@warsaw warsaw Jun 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

probably a re-entrancy problem

or maybe not, but I still prefer the approach without the added attribute.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hroncok hroncok Jun 11, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

And please add a link to the setuptools issue where they are going to remove these .pth files.

I don't think there is such an issue.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Jun 12, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

And please add a link to the setuptools issue where they are going to remove these .pth files.

I'm not aware of such issue. Do you have a link?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2026-06-11-11-52-23.gh-issue-149671.6Rpr5r.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting core review labels Jun 11, 2026
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added 2 commits June 12, 2026 15:49
@vstinner
Address Barry's review
60ae2f3
@vstinner
Remove newline change
306a06d
@vstinner

vstinner commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

@warsaw: Please review the updated PR. I don't have a link to setuptools issue/PR. I asked for such link on the issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

warsaw
warsaw approved these changes Jun 12, 2026
View reviewed changes

@warsaw warsaw left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks Victor, this looks great. If you can't dig up a setuptools link, just go ahead and commit.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting changes labels Jun 12, 2026
@vstinner

vstinner commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

Tests / Windows / Build and test (x64, tail-call) (pull_request): Failing after 11m

Ah, that's the unrelated issue gh-84649:

FAIL: test_rollover_at_midnight (test.test_logging.TimedRotatingFileHandlerTest.test_rollover_at_midnight)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner enabled auto-merge (squash) June 15, 2026 08:20
@vstinner
vstinner merged commit 18f3ffe into python:main Jun 15, 2026
96 of 99 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner deleted the sitedir branch June 15, 2026 08:29
@miss-islington-app

miss-islington-app Bot commented Jun 15, 2026

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Jun 15, 2026
@bedevere-app

bedevere-app Bot commented Jun 15, 2026

Copy link
Copy Markdown

GH-151489 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Jun 15, 2026
vstinner added a commit that referenced this pull request Jun 15, 2026
@miss-islington @vstinner
[3.15] gh-149671: Restore compatibility with setuptools -nspkg.pth fi…
f7ab7c4
…les in site module (GH-151319) (#151489)

gh-149671: Restore compatibility with setuptools -nspkg.pth files in site module (GH-151319)

Inject the "sitedir" variable in the frame which executes ".pth" code.
(cherry picked from commit 18f3ffe)

Co-authored-by: Victor Stinner <[email protected]>
@hugovk hugovk mentioned this pull request Jun 15, 2026
Local variable "sitedir" is not defined since Python 3.15.0-beta.1 sphinx-doc/sphinx#14426
Open
philthompson10 pushed a commit to philthompson10/cpython that referenced this pull request Jun 17, 2026
@vstinner @philthompson10
pythongh-149671: Restore compatibility with setuptools -nspkg.pth fil…
60919ec
…es in site module (python#151319)

Inject the "sitedir" variable in the frame which executes ".pth" code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@warsaw warsaw warsaw approved these changes
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner
+1 more reviewer
@hroncok hroncok hroncok left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@warsaw warsaw

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@vstinner @warsaw @hroncok
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.