| 277 | } |
| 278 | |
| 279 | bool CastPyArg2AttrBoolean(PyObject* obj, ssize_t arg_pos) { |
| 280 | if (obj == Py_None || obj == Py_False) { |
| 281 | return false; // To be compatible with QA integration testing. Some |
| 282 | // test cases pass in None. |
| 283 | } else if (obj == Py_True) { |
| 284 | return true; |
| 285 | } else { |
| 286 | PADDLE_THROW(common::errors::InvalidType( |
| 287 | "argument (position %d) must be " |
| 288 | "bool, but got %s", |
| 289 | arg_pos + 1, |
| 290 | (reinterpret_cast<PyTypeObject*>(obj->ob_type))->tp_name)); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | int CastPyArg2AttrInt(PyObject* obj, ssize_t arg_pos) { |
| 295 | if (PyObject_CheckLong(obj)) { |
no outgoing calls
no test coverage detected