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

With Python 3, seeing error LP_xyz instance instead of LP_xyz #92

Open
sandybandy opened this issue Dec 17, 2020 · 2 comments
Open

With Python 3, seeing error LP_xyz instance instead of LP_xyz #92

sandybandy opened this issue Dec 17, 2020 · 2 comments
Labels
need-info Need more information to proceed.

Comments

@sandybandy
Copy link

Here's the Python call and exception

attr = xyz()

myfunc(a, b, c, pointer(attr))

Above code runs fine on Python 2, but throws below exception with Python 3.7.4

ERR: argument 4: <class 'TypeError'>: expected LP_xyz instance instead of LP_xyz

C function prototype (also used to generate ctypes) is: myfunc(int a, int b, int c, xyz *p);

@Alan-R
Copy link
Collaborator

Alan-R commented Aug 1, 2021

Several things have changed (bugs fixed) in ctypesgen over the last few years. Are you running the same version of ctypesgen in python 2 as you are running in python 3?

@Alan-R Alan-R added the need-info Need more information to proceed. label Aug 1, 2021
@mara004
Copy link
Contributor

mara004 commented Dec 16, 2023

ctypesgen once had an override of the POINTER type factory (and still has with --no-embed-preamble) that destroys type checks. See also #86 (comment) and #26.

It may be related to that. My guess is that the xyz instance created and the xyz type used in the argtypes might actually originate from two separate, duplicate definitions, so they're formally recognized as different.
Use -m / --link-modules to avoid that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-info Need more information to proceed.
Projects
None yet
Development

No branches or pull requests

3 participants