Skip to content

make pointer types in ctypes.wintypes subclasses instead of aliases#11126

Merged
JelleZijlstra merged 1 commit intopython:mainfrom
tungol:wintypes
Dec 10, 2023
Merged

make pointer types in ctypes.wintypes subclasses instead of aliases#11126
JelleZijlstra merged 1 commit intopython:mainfrom
tungol:wintypes

Conversation

@tungol
Copy link
Copy Markdown
Contributor

@tungol tungol commented Dec 9, 2023

related to #3968

Comment on lines -189 to -190
# These pointer type definitions use _Pointer[...] instead of POINTER(...), to allow them
# to be used in type annotations.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed the comment because it seemed redundant: POINTER() is used to define these at runtime, but it's a runtime function. That's not appropriate for use in typeshed by definition.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 9, 2023

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Copy Markdown
Collaborator

@Avasam Avasam left a comment

Choose a reason for hiding this comment

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

Thanks! Your changes do look more correct than before:

>>> ctypes.wintypes.PBOOL       
<class 'ctypes.wintypes.LP_c_long'>
>>> type(ctypes.wintypes.PBOOL)
<class '_ctypes.PyCPointerType'>
>>> ctypes.wintypes.PBOOL.__bases__       
(<class '_ctypes._Pointer'>,)
>>> type(ctypes.wintypes.PBOOL.__bases__[0]) 
<class '_ctypes.PyCPointerType'>

@JelleZijlstra JelleZijlstra merged commit 6b9f82d into python:main Dec 10, 2023
@tungol tungol deleted the wintypes branch December 10, 2023 05:21
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