Skip to content

gh-142966: ctypes.POINTER.set_type also resets format#142967

Merged
encukou merged 5 commits intopython:mainfrom
youknowone:ctypes
Jan 26, 2026
Merged

gh-142966: ctypes.POINTER.set_type also resets format#142967
encukou merged 5 commits intopython:mainfrom
youknowone:ctypes

Conversation

@youknowone
Copy link
Contributor

@youknowone youknowone commented Dec 19, 2025

@aisk
Copy link
Member

aisk commented Jan 6, 2026

Hi, please check my comment in the original issue: #142966 (comment)

@encukou
Copy link
Member

encukou commented Jan 7, 2026

Thanks! Let's fix it even though it's deprecated.

Could you make this part of PyCPointerType_SetProto rather than add a new function that's always called after SetProto?

Please put the stginfo->format assignment in the STGINFO_LOCK block.

@youknowone
Copy link
Contributor Author

Thank you for the review!

@aisk
Copy link
Member

aisk commented Jan 18, 2026

Hi, please avoid force push in the future, see the Dev Guide.

@encukou encukou merged commit 9181d77 into python:main Jan 26, 2026
47 checks passed
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
…onGH-142967)

Make the deprecated set_type method resets the format, using the
same code as in type initialization.

Implementation note: this was done in PyCPointerType_init 
after calling PyCPointerType_SetProto, but was forgotten
after in PyCPointerType_set_type_impl's call to
PyCPointerType_SetProto.
With this change, setting the format is conceptually part of
setting proto (i.e. the pointed-to type).

Co-authored-by: AN Long <aisk@users.noreply.github.com>
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