Skip to content

gh-156491: Avoid KeyErrors in os._Environ.get() and __contains__() - #156492

Merged
ambv merged 5 commits into
python:mainfrom
alexmalyshev:environ-get
Oct 8, 2026
Merged

ambv merged 5 commits into
python:mainfrom
alexmalyshev:environ-get

Conversation

@alexmalyshev

@alexmalyshev alexmalyshev commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Implement get() and __contains__() on os._Environ directly, which cuts out the cost of raising and catching a KeyError when the keys do not exist.

Implement get() and __contains__() on os._Environ directly, which cuts out the
cost of raising and catching a KeyError when the keys do not exist.
Comment thread Lib/os.py Outdated
Comment thread Lib/os.py Outdated
@alexmalyshev

alexmalyshev commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@StanFromIreland @picnixz I don't have the capability to mark this PR as "skip news", but IMO this isn't worth adding a NEWS entry for. Anything else needed for this PR before it can it be merged?

@ambv ambv added the skip news label Oct 8, 2026
@ambv
ambv merged commit 5607381 into python:main Oct 8, 2026
51 checks passed
@alexmalyshev
alexmalyshev deleted the environ-get branch October 8, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants