Last active
February 21, 2020 04:27
-
-
Save wkcn/501cd118b8ceb1608bd6c8fa968e7912 to your computer and use it in GitHub Desktop.
testdel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
from ctypes import * | |
ctypes.pythonapi.PyCapsule_New.restype = ctypes.py_object | |
ctypes.pythonapi.PyCapsule_New.argtypes = [ctypes.c_void_p, ctypes.c_char_p, | |
ctypes.c_void_p] | |
def dfunc(dltensor): | |
pass | |
cfunc = ctypes.CFUNCTYPE(None, ctypes.c_void_p) | |
def test(): | |
a = ctypes.pythonapi.PyCapsule_New(1, b'dltensor', cfunc(dfunc)) | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mkmoisen,
Hi Matthew,
There was a bug in my gist code.
In the line 11,
cfunc = ctypes.CFUNCTYPE(None, ctypes.py_object)
is wrong.The type of parameter should be
ctypes.c_void_p
rather thanctypes.py_object
. I have fixed it.Thanks,
wkcn