Hey Gang, why is the below snippet for error checking not working? I wan't to be able to pass in different PyTypeObjects to the CHECK_TYPE function and check an object for that type. It works fine when I insert put &PyString_Type directly into the function like so --> if ( ! PyObject_TypeCheck(s_obj, &PyString_type) ) However, the CHECK_TYPE function will return -1 if I pass the PyTypeObject in, like at the bottom of this message. Why does PyObject_TypeCheck not work if PyTypeObject is first passed into a function?
int CHECK_TYPE(PyObject *s_obj, PyTypeObject obj_type) { if ( ! s_obj ) return 1;
if ( ! PyObject_TypeCheck(s_obj, &obj_type) ) { PyErr_Format(PyExc_TypeError, "[ %s ] object needs to be of type [ %s ]\n\nUsage: %s", PyString_AsString(PyObject_Repr(s_obj)), obj_type.tp_name, obj_type.tp_doc ); return -1; }
return 1;
}
if ( !CHECK_TYPE(align, PyString_Type) ) return NULL;
-- Bust0ut, Surgemcgee: Systems Engineer --- surgemcgee.com Django_Teamplate3d