| 315 | } |
| 316 | |
| 317 | int CastPyArg2Int(PyObject* obj, const std::string& op_type, ssize_t arg_pos) { |
| 318 | if (PyObject_CheckLong(obj)) { |
| 319 | return PyObject_ToInt32(obj); |
| 320 | } else { |
| 321 | PADDLE_THROW(common::errors::InvalidType( |
| 322 | "%s(): argument (position %d) must be " |
| 323 | "int, but got %s", |
| 324 | op_type, |
| 325 | arg_pos + 1, |
| 326 | ((PyTypeObject*)obj->ob_type)->tp_name)); // NOLINT |
| 327 | } |
| 328 | |
| 329 | return 0; |
| 330 | } |
| 331 | int CastPyArg2Int(PyObject* obj, |
| 332 | const std::string& op_type, |
| 333 | ssize_t arg_pos, |
no test coverage detected