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-120057: Add os.reload_environ() function by vstinner · Pull Request #126268 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Nov 1, 2024 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Replace the os.environ.refresh() method with a new os.reload_environ() function.

  • Issue: Add os.reload_environ() function #120057

📚 Documentation preview 📚: https://cpython-previews--126268.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

EDM115 reacted with hooray emoji ncoghlan reacted with heart emoji
All reactions
  • 🎉 1 reaction
  • ❤️ 1 reaction
@vstinner
pythongh-120057: Add os.reload_environ() function
0a00444
Replace the os.environ.refresh() method with a new
os.reload_environ() function.
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 1, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Nov 1, 2024
Add os.reload_environ() function #120057
Closed
serhiy-storchaka
serhiy-storchaka reviewed Nov 1, 2024
View reviewed changes
Comment thread Doc/library/os.rst Outdated
.. function:: reload_environ()

Update :data:`os.environ` and :data:`os.environb` with changes to the
environment made by :func:`os.putenv`, by :func:`os.unsetenv`, or made

@serhiy-storchaka serhiy-storchaka Nov 1, 2024

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.

I think that it is better to say "the process environment".
os.putenv and os.unsetenv update the cache, so there is no need to reload after them. You should refer to the C functions.
Please add a note that this function is not thread safe. Calling it while the environment is modified in other thread has undefined behavior. Reading from os.environ or calling os.getenv during reloading can return empty result.

Sorry, something went wrong.

Uh oh!

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

rruuaanng reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@rruuaanng rruuaanng Nov 1, 2024 •
edited
Loading

Uh oh!

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

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.

If the process environment is mentioned, perhaps it can be specifically mentioned that it is the current process environment (I think)

Edit
Or, it can be called the current program.

Sorry, something went wrong.

Uh oh!

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

All reactions

@vstinner vstinner Nov 1, 2024

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.

os.putenv() and os.unsetenv() don't update os.environ: see test_reload_environ().

Sorry, something went wrong.

Uh oh!

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

serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@vstinner
Address review: complete doc
ad10366
@vstinner

vstinner commented Nov 1, 2024

Copy link
Copy Markdown
Member Author

@serhiy-storchaka: Please review the updated PR. I addressed your review.

All reactions

Sorry, something went wrong.

Uh oh!

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

serhiy-storchaka
serhiy-storchaka approved these changes Nov 1, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka 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.

LGTM. Let a native speaker to review the wording.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/library/os.rst Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Nov 1, 2024
@vstinner
Add seealso to os.environ
118b8c0
@vstinner

vstinner commented Nov 1, 2024

Copy link
Copy Markdown
Member Author

cc @zooba @ncoghlan

All reactions

Sorry, something went wrong.

Uh oh!

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

picnixz
picnixz reviewed Nov 1, 2024
View reviewed changes

@picnixz picnixz 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.

Not a native speaker but here are some suggestions. For native speakers: @python/proofreaders

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/library/os.rst Resolved

Uh oh!

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

Comment thread Doc/library/os.rst Resolved

Uh oh!

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

Comment thread Doc/library/os.rst Resolved

Uh oh!

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

@vstinner @picnixz
Apply suggestions from code review
fde06e9
Co-authored-by: Bénédikt Tran <[email protected]>
@vstinner

vstinner commented Nov 1, 2024

Copy link
Copy Markdown
Member Author

@picnixz: I applied your suggestions.

picnixz reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

AA-Turner
AA-Turner reviewed Nov 1, 2024
View reviewed changes
Comment thread Doc/library/os.rst Resolved

Uh oh!

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

ncoghlan
ncoghlan approved these changes Nov 1, 2024
View reviewed changes

@ncoghlan ncoghlan left a comment

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.

LGTM! (although see @AA-Turner's suggested docs wording tweaks)

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner @AA-Turner
Update Doc/library/os.rst
ca90336
Co-authored-by: Adam Turner <[email protected]>
cmaloney
cmaloney approved these changes Nov 1, 2024
View reviewed changes
picnixz
picnixz approved these changes Nov 2, 2024
View reviewed changes

@picnixz picnixz 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.

Pro tips from someone who had lots of linter errors due to suggestions in the past: when submitting a suggestion, I usually Ctrl+A (or "Select all" on mobile) to check whether the text has trailing whitespaces or not. This helps reducing linter errors.

Sorry, something went wrong.

Uh oh!

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

ncoghlan reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Doc/library/os.rst Resolved

Uh oh!

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

AA-Turner
AA-Turner approved these changes Nov 2, 2024
View reviewed changes
@vstinner @picnixz
Update Doc/library/os.rst
1b07ef6
Co-authored-by: Bénédikt Tran <[email protected]>
zooba
zooba approved these changes Nov 4, 2024
View reviewed changes

@zooba zooba 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.

Looks great to me!

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner
vstinner merged commit 4a0d574 into python:main Nov 5, 2024
@vstinner
vstinner deleted the reload_environ branch November 5, 2024 07:43
@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 5, 2024
@vstinner

vstinner commented Nov 5, 2024

Copy link
Copy Markdown
Member Author

Merged, thanks for reviews!

All reactions

Sorry, something went wrong.

Uh oh!

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

picnixz added a commit to picnixz/cpython that referenced this pull request Dec 8, 2024
@vstinner @picnixz @AA-Turner
pythongh-120057: Add os.reload_environ() function (python#126268)
610da8f
Replace the os.environ.refresh() method with a new
os.reload_environ() function.

Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
@vstinner @picnixz
@AA-Turner @ebonnal
pythongh-120057: Add os.reload_environ() function (python#126268)
1960b30
Replace the os.environ.refresh() method with a new
os.reload_environ() function.

Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
@AlexWaygood AlexWaygood mentioned this pull request Oct 29, 2025
gh-120057: add os.reload_environ to __all__ #140763
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ncoghlan ncoghlan ncoghlan approved these changes
@cmaloney cmaloney cmaloney approved these changes
@zooba zooba zooba approved these changes
@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@AA-Turner AA-Turner AA-Turner approved these changes
@picnixz picnixz picnixz approved these changes
+1 more reviewer
@rruuaanng rruuaanng rruuaanng left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

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.

8 participants

@vstinner @cmaloney @ncoghlan @zooba @serhiy-storchaka @AA-Turner @picnixz @rruuaanng
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.