Skip to content

Typing of ctypes' pointer types is wrong #8351

Closed

Description

@svenpanne

https://docs.python.org/3/library/ctypes.html#pointers explicitly says:

Calling the pointer type without an argument creates a NULL pointer.

and even has a code example for this:

null_ptr = POINTER(c_int)()

But the pointer constructor

def __init__(self, arg: _CT) -> None: ...
requires an argument. This should be optional if I understand the code there correctly.

Activity

  1. AlexWaygood commented on Jul 21, 2022

    @AlexWaygood
    Member

    Hum, this was probably my mistake. I changed this in #8074 due to observing this behaviour in the interactive REPL:

    >>> from ctypes import pointer
    >>> pointer()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: _ctypes.pointer() takes exactly one argument (0 given)
  2. AlexWaygood commented on Jul 21, 2022

    @AlexWaygood
    Member

    The entire ctypes stub appears to be a lie (pointer() is given as a class, but in reality it's a function). Ideally I think we'd fix that, but that might be a breaking change. Not really sure what the best course of action is tbh.

  3. srittau commented on Jul 21, 2022

    @srittau
    Collaborator

    If there only was a way to judge the impact of a change. 🤔 But seriously, I would just try the changes and see whether primer explodes.

  4. AlexWaygood commented on Jul 21, 2022

    @AlexWaygood
    Member

    If there only was a way to judge the impact of a change. 🤔 But seriously, I would just try the changes and see whether primer explodes.

    I'll get on it.

  5. self-assigned this
    on Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions