You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pointer to bind(c) struct does not work in CPython #2134
This works with LPython, but fails in CPython with:
$ PYTHONPATH=src/runtime/lpython python integration_tests/structs_02b.py c_void_p(4346287752) c_void_p(4346287752)Traceback (most recent call last): File "/Users/ondrej/repos/lpython/integration_tests/structs_02b.py", line 22, in <module> f() File "/Users/ondrej/repos/lpython/integration_tests/structs_02b.py", line 17, in f x = a2.xAttributeError: 'c_void_p' object has no attribute 'x'
The fix there is:
--- a/src/runtime/lpython/lpython.py+++ b/src/runtime/lpython/lpython.py@@ -670,10 +670,7 @@ def pointer(x, type_=None):
return ctypes.cast(ctypes.pointer(ctypes.c_double(x)),
ctypes.c_void_p)
elif is_dataclass(type_):
- if issubclass(type_, ctypes.Structure):- return ctypes.cast(ctypes.pointer(x), ctypes.c_void_p)- else:- return x+ return x
else:
raise Exception("Type not supported in pointer()")
But this makes many other tests fail, things start to fall apart, so this requires further investigation.
Activity