From: SourceForge.net <no...@so...> - 2011-10-27 17:54:53
|
Bugs item #3429388, was opened at 2011-10-27 10:54 Message generated for change (Tracker Item Submitted) made by weihongbin You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3429388&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Hongbin Wei (weihongbin) Assigned to: Nobody/Anonymous (nobody) Summary: not handling 0xffffffff correctly as UINT32 input to C func Initial Comment: 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 lines of following method marked by "<==". Obviously 0xffffffff is being treated as a singed value although it's expected to be an unsigned. 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; } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3429388&group_id=1645 |