Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-39264: Fix UserDict.get() to account for __missing__() #17910

Merged
merged 11 commits into from
May 10, 2022

Conversation

bharel
Copy link
Contributor

@bharel bharel commented Jan 9, 2020

Here's the patch according to the discussion at the Python-Dev mailing list.
UserDict.get() will match dict's behavior and not call __missing__.

https://bugs.python.org/issue39264

Automerge-Triggered-By: GH:rhettinger

@bharel
Copy link
Contributor Author

bharel commented Jan 9, 2020

Seems like ubuntu's archives are down.

Lib/collections/__init__.py Show resolved Hide resolved
Lib/test/test_collections.py Outdated Show resolved Hide resolved
if key in self:
return self[key]
return default

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Only one blank line so as to match the surrounding code.

def __contains__(self, key):
return key in self.data

def get(self, key, default=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment that get() is overridden to avoid a False positive when _missing_ is defined.

@rhettinger
Copy link
Contributor

Closing and reopening to trigger the CI bots.

@miss-islington
Copy link
Contributor

@bharel: Status check is done, and it's a success ✅ .

kenodegard added a commit to johnnynunez/conda that referenced this pull request Dec 11, 2023
Python 3.12 no longer calls `UserDict.__missing__`. See python/cpython#17910.
kenodegard added a commit to conda/conda that referenced this pull request Dec 12, 2023
Required a fix for fetching aliases from `RepodataState` since Python 3.12 no longer calls `UserDict.__missing__`. See python/cpython#17910.

---------

Co-authored-by: Travis Hathaway <[email protected]>
Co-authored-by: Jannis Leidel <[email protected]>
Co-authored-by: Ken Odegard <[email protected]>
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.

6 participants