Commit 6206e1a0 authored by Stefan Behnel's avatar Stefan Behnel

minor improvements in __Pyx_ArgTypeTest() and prevent it from raising C...

minor improvements in __Pyx_ArgTypeTest() and prevent it from raising C compiler warnings by inlining it
parent 47deba00
//////////////////// ArgTypeTest.proto ////////////////////
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact); /*proto*/
//////////////////// ArgTypeTest ////////////////////
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
PyErr_Format(PyExc_TypeError,
"Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact)
{
if (!type) {
if (unlikely(!type)) {
PyErr_Format(PyExc_SystemError, "Missing type object");
return 0;
}
......@@ -16,15 +22,13 @@ static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed
else if (exact) {
if (likely(Py_TYPE(obj) == type)) return 1;
#if PY_MAJOR_VERSION == 2
else if ((type == &PyBaseString_Type) && __Pyx_PyBaseString_CheckExact(obj)) return 1;
else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
#endif
}
else {
if (PyObject_TypeCheck(obj, type)) return 1;
if (likely(PyObject_TypeCheck(obj, type))) return 1;
}
PyErr_Format(PyExc_TypeError,
"Argument '%s' has incorrect type (expected %s, got %s)",
name, type->tp_name, Py_TYPE(obj)->tp_name);
__Pyx_RaiseArgumentTypeInvalid(name, obj, type);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment