Skip to content

ctypes: add __ctype_{be,le}__ class attributes#15642

Open
jorenham wants to merge 2 commits intopython:mainfrom
jorenham:ctypes/endian-class-attrs
Open

ctypes: add __ctype_{be,le}__ class attributes#15642
jorenham wants to merge 2 commits intopython:mainfrom
jorenham:ctypes/endian-class-attrs

Conversation

@jorenham
Copy link
Copy Markdown
Contributor

These class attributes are used when swapping endianness:

>>> import ctypes as ct
>>> ct.c_double.__ctype_le__ is ct.c_double.__ctype_be__
False

There should be need to distinguish between these little- and big-endian type flavors in typeshed, because as far as I can tell, their interfaces are statically equivalent.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/aglib/heap/structs.py: note: In member "read_field" of class "CStruct2GDB":
+ pwndbg/aglib/heap/structs.py:186: error: Invalid index type "type[_SimpleCData[Any]] | type[_Pointer[Any]] | type[CFuncPtr]" for "dict[type[_SwappableCData], Type]"; expected type "type[_SwappableCData]"  [index]
+ pwndbg/aglib/heap/structs.py: note: In member "fields" of class "CStruct2GDB":
+ pwndbg/aglib/heap/structs.py:217: error: Invalid index type "type[_SimpleCData[Any]] | type[_Pointer[Any]] | type[CFuncPtr]" for "dict[type[_SwappableCData], Type]"; expected type "type[_SwappableCData]"  [index]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/computation/ops.py:328: error: Need type annotation for "_binary_ops_dict" (hint: "_binary_ops_dict: dict[<type>, <type>] = ...")  [var-annotated]

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