From: Hongbin W. - S. <hon...@si...> - 2011-10-26 07:08:38
|
I have a C function "void Uint32_Test(UINT32 num)". when I pass in a 0xffffffff as the argument from Python to the wrapper function, I get "overflowerror : in method 'Uint32_Test', argument 1 of type 'UINT32'". Looking into the wrappers, I found that the error is generated at the highlighted line of following method. Obviously 0xffffffff is being treated as a singed value. What should I do if I still want to pass in 0xffffffff as a UINT32 for the wrapper function? Thanks. SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { long v = PyInt_AsLong(obj); if (v >= 0) { if (val) *val = v; return SWIG_OK; } else { return SWIG_OverflowError; } } else if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { if (val) *val = (unsigned long)(d); return res; } } } #endif return SWIG_TypeError; } Hongbin Wei Firmware Engineer, SAS SSD 408.544.5879(o) 408.876.0659(m) |