Hi,
I am currently porting some of my applications to U3 (www.u3.com) and I do
get a crash in ...objects\fram eobject.c: PyFrameObject *back =
tstate->frame.
The point of the current test is to get a python function called on a U3
device event. (U3 only work with Windows currently).
My C stub callback does get called but crashes when it tries to call the
python function.
*************** ************
This is the function that registers the callback (actual dll prototype in
header):
*************** ************
static PyObject *s_callback=NUL L;
/*************** *************** *************** *************** ******/
/*************** *************** *************** *************** ******/
/* HRESULT dapiRegisterCal lback ( HSESSION hSession ,wchar_t*
pszConnectionSt ring ,DAPI_CALLBACK pCallBack,void* pEx ,HCALLBACK*
hCallback) */
/*************** *************** *************** *************** ******/
/*************** *************** *************** *************** ******/
static PyObject *Py_dapiRegiste rCallback(PyObj ect *p_self, PyObject *p_args)
{
HRESULT l_result;
HSESSION l_hSession;
wchar_t* l_pszConnection String;
PyObject *l_tmp_cb;
//PyObject cs;
void* l_pEx;
HCALLBACK l_hCallback;
if
(!PyArg_ParseTu ple(p_args,"iuO i",&l_hSession, &l_pszConnectio nString,&l_tmp_ cb,&l_pEx) )
{
BAD_PARAM;
return NULL;
}
//l_pszConnection String = PyObject_Unicod e(cs);
Py_XINCREF(l_tm p_cb);
Py_XDECREF(s_ca llback);
s_callback=l_tm p_cb;
l_result =
dapiRegisterCal lback(l_hSessio n,l_pszConnecti onString,Stub_C allback,l_pEx,& l_hCallback);
CHECK_RESULT;
return Py_BuildValue(" l",l_hCallback) ;
}
*************** *************** *********
This is the stub callback that crashes:
*************** *************** *********
void _stdcall Stub_Callback(H DEVICE p_dev, DWORD p_event, void *p_pEx)
{
PyObject *l_result;
PyObject *l_arg_list;
l_arg_list = Py_BuildValue(" (iii)", p_dev,p_event,p _pEx);
l_result = PyEval_CallObje ct(s_callback, l_arg_list); /*No crash if I
comment this line*/
Py_DECREF(l_arg _list);
}
*************** *************** ***********
This is the python source
*************** *************** ***********
(cs, and s have a correct value ... I think )
import u3
def mf(a,b,c):
print 'CB'
h=u3.dapiRegist erCallback(s, cs, mf, 0)
Any help _greatly_ appreciated.
Regards,
Philippe
I am currently porting some of my applications to U3 (www.u3.com) and I do
get a crash in ...objects\fram eobject.c: PyFrameObject *back =
tstate->frame.
The point of the current test is to get a python function called on a U3
device event. (U3 only work with Windows currently).
My C stub callback does get called but crashes when it tries to call the
python function.
*************** ************
This is the function that registers the callback (actual dll prototype in
header):
*************** ************
static PyObject *s_callback=NUL L;
/*************** *************** *************** *************** ******/
/*************** *************** *************** *************** ******/
/* HRESULT dapiRegisterCal lback ( HSESSION hSession ,wchar_t*
pszConnectionSt ring ,DAPI_CALLBACK pCallBack,void* pEx ,HCALLBACK*
hCallback) */
/*************** *************** *************** *************** ******/
/*************** *************** *************** *************** ******/
static PyObject *Py_dapiRegiste rCallback(PyObj ect *p_self, PyObject *p_args)
{
HRESULT l_result;
HSESSION l_hSession;
wchar_t* l_pszConnection String;
PyObject *l_tmp_cb;
//PyObject cs;
void* l_pEx;
HCALLBACK l_hCallback;
if
(!PyArg_ParseTu ple(p_args,"iuO i",&l_hSession, &l_pszConnectio nString,&l_tmp_ cb,&l_pEx) )
{
BAD_PARAM;
return NULL;
}
//l_pszConnection String = PyObject_Unicod e(cs);
Py_XINCREF(l_tm p_cb);
Py_XDECREF(s_ca llback);
s_callback=l_tm p_cb;
l_result =
dapiRegisterCal lback(l_hSessio n,l_pszConnecti onString,Stub_C allback,l_pEx,& l_hCallback);
CHECK_RESULT;
return Py_BuildValue(" l",l_hCallback) ;
}
*************** *************** *********
This is the stub callback that crashes:
*************** *************** *********
void _stdcall Stub_Callback(H DEVICE p_dev, DWORD p_event, void *p_pEx)
{
PyObject *l_result;
PyObject *l_arg_list;
l_arg_list = Py_BuildValue(" (iii)", p_dev,p_event,p _pEx);
l_result = PyEval_CallObje ct(s_callback, l_arg_list); /*No crash if I
comment this line*/
Py_DECREF(l_arg _list);
}
*************** *************** ***********
This is the python source
*************** *************** ***********
(cs, and s have a correct value ... I think )
import u3
def mf(a,b,c):
print 'CB'
h=u3.dapiRegist erCallback(s, cs, mf, 0)
Any help _greatly_ appreciated.
Regards,
Philippe
Comment