Skip to content

__ctype_{be,le}__ attributes missing for ctypes.c_*_complex types #148464

@jorenham

Description

@jorenham

Bug report

Bug description:

I was working on adding support for the fancy new complex ctypes types to numpy.ctypeslib 1, but ran into the problem that the c_{float,double,longdouble}_complex types do not have the __ctype_{be,le}__ attributes that e.g. their non-complex counterparts have:

>>> import ctypes as ct
>>> ct.c_float.__ctype_le__
<class 'ctypes.c_float'>
>>> ct.c_float_complex.__ctype_le__
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    ct.c_float_complex.__ctype_le__
AttributeError: type object 'c_float_complex' has no attribute '__ctype_le__'

I checked Python 3.14.4 and 3.15.0a8.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Footnotes

  1. NumPy relies on these attributes when converting e.g. numpy.dtype(">d") to ctypes.c_double.__ctype_be__ using numpy.ctypeslib.as_ctypes_type (docs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions