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

Fix sequences that can be cast into PyMapping #2098

Closed
wants to merge 1 commit into from

Conversation

aviramha
Copy link
Member

Fixes #2072
Thanks @aganders3 for the finding the workaround.

… can be cast to `PyMapping`) due to `PyMapping_Check` returning true for sequences.
@aviramha
Copy link
Member Author

I think tests are broken due to main being broken?

@aganders3
Copy link
Contributor

I think tests are broken due to main being broken?

Yes seems like it coincides with the 1.58 release. Mostly UI tests failing from what I see.

@mejrs
Copy link
Member

mejrs commented Jan 13, 2022

Yes, this is because of 1.58 I'll try to fix it ⚒️

@davidhewitt
Copy link
Member

davidhewitt commented Jan 13, 2022

Hmmm, this is clever but I'm unsure it's the right fix.

As far as I know, classes implemented in Python with a __getitem__ will pass both PyMapping_Check and PySequence_Check, and so never be convertible to PyMapping with this change.

I was also proposing to match the Python behavior in #2065, which would mean PyO3 mappings would also fail this check.

Maybe we need to ask for help from upstream?

@aganders3
Copy link
Contributor

Ah, bummer.

As far as I know, classes implemented in Python with a getitem will pass both PyMapping_Check and PySequence_Check, and so never be convertible to PyMapping with this change.

Yeah I think this is true unless they also subclass dict.

@aviramha
Copy link
Member Author

Closing this, let's return to the original issue to discuss.

@aviramha aviramha closed this Jan 14, 2022
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.

PyMapping is inconsistent with typing.Mapping
4 participants