| 348 | } |
| 349 | |
| 350 | int64_t CastPyArg2Long(PyObject* obj, |
| 351 | const std::string& op_type, |
| 352 | ssize_t arg_pos) { |
| 353 | if (PyObject_CheckLong(obj)) { |
| 354 | return PyObject_ToInt64(obj); |
| 355 | } else { |
| 356 | PADDLE_THROW(common::errors::InvalidType( |
| 357 | "%s(): argument (position %d) must be " |
| 358 | "long, but got %s", |
| 359 | op_type, |
| 360 | arg_pos + 1, |
| 361 | ((PyTypeObject*)obj->ob_type)->tp_name)); // NOLINT |
| 362 | } |
| 363 | |
| 364 | return 0; |
| 365 | } |
| 366 | int64_t CastPyArg2Long(PyObject* obj, |
| 367 | const std::string& op_type, |
| 368 | ssize_t arg_pos, |
no test coverage detected