Skip to content

Call PyObject_GetBuffer directly, fix pypy fail #2639

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

Merged
merged 1 commit into from
Dec 30, 2023
Merged

Conversation

ankith26
Copy link
Member

So, with the latest pypy version, we have new test fails. What's happening now on pypy is that PyObject_CheckBuffer passes but PyObject_GetBuffer fails, and the old code is forwarding the error in this case, but it's better to instead go down the array interface/struct fallback and then error if all those fail.

I have intentionally kept this PR minimal so that it is easy to review, despite my itch to refactor the whole function to make it neater :)

@ankith26 ankith26 requested a review from a team as a code owner December 28, 2023 18:01
@ankith26
Copy link
Member Author

If this works and is merged, this will need backporting to the 2.4.x branch before the release, because otherwise circleci is going to fail on it, when it makes the release wheels

@ankith26 ankith26 added this to the 2.4.0 milestone Dec 28, 2023
@Starbuck5
Copy link
Member

Is this a bug in pypy-- should this be reported to them?

@ankith26
Copy link
Member Author

ankith26 commented Dec 29, 2023

According to the python docs for PyObject_CheckBuffer

Return 1 if obj supports the buffer interface otherwise 0. When 1 is returned, it doesn’t guarantee that PyObject_GetBuffer() will succeed. This function always succeeds.

So maybe it could be considered a PyPy regression, but the new behaviour is still inline with what the docs say, so instead doing a fix on our end is better IMO.

Copy link
Member

@Starbuck5 Starbuck5 left a comment

Choose a reason for hiding this comment

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

Ok I guess? The change is small and looks like it will function the same, except for the different error.

I don't feel confident about how the buffers work in pygame, or what is going on with pypy there. Is failing a different way making the tests pass or does this cause it to not fail at all?

I still feel that this might be a good thing to report to pypy. If it's an intentional change they can say so, but it seems like it could be unintentional.

@ankith26
Copy link
Member Author

Is failing a different way making the tests pass or does this cause it to not fail at all?

The tests pass because now there is no fail at all.

I still feel that this might be a good thing to report to pypy. If it's an intentional change they can say so, but it seems like it could be unintentional.

Yeah, maybe. Though I'd still like this patch in because it would work regardless of their decision, and as of now it is not failing on any config we support

Copy link
Member

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@MyreMylar MyreMylar merged commit 8666e9d into main Dec 30, 2023
@ankith26 ankith26 deleted the ankith26-pypy-fix branch January 2, 2024 17:52
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.

3 participants