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

Import error on Python 3.8 #16

Open
alandmoore opened this issue Jan 9, 2020 · 5 comments
Open

Import error on Python 3.8 #16

alandmoore opened this issue Jan 9, 2020 · 5 comments

Comments

@alandmoore
Copy link
Contributor

When importing pypxlib on Python 3.8 I get the following:

Traceback (most recent call last):
  File "/usr/lib/python3.8/ctypes/__init__.py", line 99, in CFUNCTYPE
    return _c_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.c_void_p'>, (<class 'pypxlib.pxlib_ctypes.py3.LP_struct_px_doc'>, <class 'ctypes.c_int'>, <class 'pypxlib.pxlib_ctypes.py3.String'>, <class 'ctypes.c_void_p'>), 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/alanm/.local/lib/python3.8/site-packages/pypxlib/__init__.py", line 4, in <module>
    from pypxlib.pxlib_ctypes import *
  File "/home/alanm/.local/lib/python3.8/site-packages/pypxlib/pxlib_ctypes/__init__.py", line 15, in <module>
    from pypxlib.pxlib_ctypes.py3 import *
  File "/home/alanm/.local/lib/python3.8/site-packages/pypxlib/pxlib_ctypes/py3.py", line 951, in <module>
    ('errorhandler', CFUNCTYPE(UNCHECKED(None), POINTER(pxdoc_t), c_int, String, POINTER(None))),
  File "/usr/lib/python3.8/ctypes/__init__.py", line 101, in CFUNCTYPE
    class CFunctionType(_CFuncPtr):
TypeError: item 3 in _argtypes_ passes a union by value, which is unsupported.

This is on Arch Linux running Python 3.8.1. pypxlib from pypi.

@alandmoore
Copy link
Contributor Author

Interestingly, I get the same error if I install Python 3.7.6 on this computer, but I don't get it with Python 3.7.2 on Debian.

pxlib 0.6.8-1 is installed on the Arch system, pxlib 0.6.7-1 on Debian.

@alandmoore
Copy link
Contributor Author

I did attempt generating a new py3.py file using ctypesgenerator, but I end up with the exact same call to CFUNCTYPE that causes the same error.

I also, rather naively, wrapped all the String uses in CFUNCTYPE calls with a POINTER. This stopped the import error, but pretty much broke the whole library. I really know almost nothing about ctypes, so I'm just swinging wildly at this issue.

@airelil
Copy link

airelil commented Jan 11, 2020

Most probably related to: python/cpython#16799

@alandmoore
Copy link
Contributor Author

@airelil Ah yes, looks like it. What a mess.

@airelil
Copy link

airelil commented Jan 15, 2020

Good news, they are reverting the change: python/cpython#17960

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

2 participants