Skip to content

ctypes._FuncPointer doesn't exist at runtime and _ctypes.CFuncPtr doesn't exist in typestub #10132

Closed

Description

@junkmd

Quoting from #9251 (comment);

  • Our stub has a _FuncPointer class that doesn't exist at runtime. But in fact, the code returns a subclass of _ctypes.CFuncPtr, so why don't we use that class in the stubs?

In addition, Python's ctypes runtime namespace is defined by the following lines;


I think the following way can be improved with less changes and less impact.

  1. move the definition of _FuncPointer to _ctypes.pyi.
  2. change the class name to CFuncPtr.
  3. add from _ctypes import CFuncPtr as _CFuncPtr line to ctypes/__init__.pyi.
  4. add class _FuncPointer(_CFuncPtr): ... line.

The ctypes._FuncPointer will be conceptualized as "a dynamically generated subclass of _ctypes.CFuncPtr".


this issue is related to #8968, #8571 (comment) and #8633 (comment)

Activity

  1. junkmd commented on May 6, 2023

    @junkmd
    ContributorAuthor

    #10140 has been merged and the definition movings are completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions