Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
junkmd opened this issue May 3, 2023 · 1 comment

Comments

@junkmd
Copy link
Contributor

junkmd commented May 3, 2023

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)

@junkmd
Copy link
Contributor Author

junkmd commented May 6, 2023

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

@junkmd junkmd closed this as completed May 6, 2023
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

No branches or pull requests

1 participant