Skip to content

FIx PySequence_AsVectorCoords and discourage usage #3487

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ankith26
Copy link
Member

@ankith26 ankith26 commented Jun 8, 2025

Whenever is PySequence_AsVectorCoords is called without calling pgVectorCompatible_Check beforehand, currently the code gives undefined behaviour when expected dim is 3 and a Vector2 is passed. If expected dim is 2 and Vector3 is passed the 3rd component gets ignored. For now I fixed the undefined behaviour case to ensure consistent 0-ing.

I renamed this function to pg_VectorCoordsFromObjOldDontUseInNewCode so that new API doesn't end up using this function. New API should just use pg_VectorCoordsFromObj directly.

Wherever pgVectorCompatible_Check was already being called before PySequence_AsVectorCoords we can safely use the new pg_VectorCoordsFromObj API

@ankith26 ankith26 requested a review from a team as a code owner June 8, 2025 07:06
@ankith26 ankith26 force-pushed the ankith26-math-api branch from 0b596da to 92b99c6 Compare June 8, 2025 07:12
@ankith26 ankith26 force-pushed the ankith26-math-api branch from 92b99c6 to fd2bcae Compare June 8, 2025 07:17
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.

1 participant