Title: os._Environ.get() and __contains__() raise and catch KeyError internally · Issue #156491 · python/cpython · GitHub
Open Graph Title: os._Environ.get() and __contains__() raise and catch KeyError internally · Issue #156491 · python/cpython
X Title: os._Environ.get() and __contains__() raise and catch KeyError internally · Issue #156491 · python/cpython
Description: Feature or enhancement Proposal: Since os._Environ is a subclass of collections.abc.Mapping, its get() and __contains__() methods are implemented in terms of __getitem__(). By forwarding to __getitem__(), a KeyError is raised when the ke...
Open Graph Description: Feature or enhancement Proposal: Since os._Environ is a subclass of collections.abc.Mapping, its get() and __contains__() methods are implemented in terms of __getitem__(). By forwarding to __getit...
X Description: Feature or enhancement Proposal: Since os._Environ is a subclass of collections.abc.Mapping, its get() and __contains__() methods are implemented in terms of __getitem__(). By forwarding to __getit...
Opengraph URL: https://github.com/python/cpython/issues/156491
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"os._Environ.get() and __contains__() raise and catch KeyError internally","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nSince `os._Environ` is a subclass of `collections.abc.Mapping`, its `get()` and `__contains__()` methods are implemented in terms of `__getitem__()`. By forwarding to `__getitem__()`, a `KeyError` is raised when the key does not exist. This `KeyError` is then immediately caught and swallowed.\n\nHandling this exception is extra, avoidable work. `_Environ` can check its internal dictionary directly which is more efficient.\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156492\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/alexmalyshev","@type":"Person","name":"alexmalyshev"},"datePublished":"2026-08-27T19:11:47Z","url":"https://github.com/python/cpython/issues/156491"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3d6294c4-59ba-7b9b-4991-9098bcddc6e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 958A:2A7C1C:18CC908:20C372B:6B020F48 |
| html-safe-nonce | 16f2fa7f07168f654173b194301f23c29fe67c2ef7b02ba45ab865ef63e85257 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NThBOjJBN0MxQzoxOENDOTA4OjIwQzM3MkI6NkIwMjBGNDgiLCJ2aXNpdG9yX2lkIjoiMzczMDM2NTk4MDk4ODI4MDY0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 95a8b46fb02d6a99cc31af2a55aa96c4e20876ad5cd0eb9f6213e269db2d565f |
| hovercard-subject-tag | issue:5271231712 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156491/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d08e35a62ff5bb4bb4555278b915c04c62d01c595b9c7e5cf759f2e7e922e814/python/cpython/issues/156491 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d08e35a62ff5bb4bb4555278b915c04c62d01c595b9c7e5cf759f2e7e922e814/python/cpython/issues/156491 |
| og:image:alt | Feature or enhancement Proposal: Since os._Environ is a subclass of collections.abc.Mapping, its get() and __contains__() methods are implemented in terms of __getitem__(). By forwarding to __getit... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexmalyshev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width