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

Non-exact stub file preventing mypyc modules from running #1032

Open
rianhunter opened this issue Nov 12, 2023 · 1 comment
Open

Non-exact stub file preventing mypyc modules from running #1032

rianhunter opened this issue Nov 12, 2023 · 1 comment

Comments

@rianhunter
Copy link

The class hierarchy in the _ctypes stub don't mirror the real module exactly. This doesn't prevent mypy from type-checking but it may prevent modules compiled with mypyc from running. Here is a test file

import _ctypes

class c_timespec(_ctypes.Structure):
    pass

Now if I try to import the built module:

$ python3
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test.py", line 7, in <module>
    class c_win_timespec(ctypes.Structure):
AttributeError: module '_ctypes' has no attribute '_StructUnionBase'

This is because there is no _StructUnionBase in the real _ctypes module but there is one in the stub.

Who is at fault here? Is the stub file broken? Or does mypyc need to be extended to handle this case?

@rianhunter
Copy link
Author

Note: I am happy to put all the effort into fixing this issue if someone can clarify what component is at fault here.

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