Skip to content

ctypes.Array should be abstract #6349

@sobolevn

Description

@sobolevn

Right now Array in ctypes is a regular class:

class Array(Generic[_CT], _CData):
_length_: ClassVar[int]

But, in reallity - you cannot instantiate it:

>>> from ctypes import Array, c_int
>>> i = c_int(1)
>>> Array(i)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: abstract class

Mypy is also not happy with Array(...) but for other reasons:

out/ex.py:4: error: Array constructor argument 1 of type "c_int" is not convertible to the array element type <nothing>
out/ex.py:4: note: Revealed type is "ctypes.Array[<nothing>]"

Array(...) is not tested in https://github.com/python/mypy/blob/master/test-data/unit/check-ctypes.test at all

Metadata

Metadata

Assignees

No one assigned

    Labels

    reason: inexpressibleClosed, because this can't be expressed within the current type system

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions