int64_t
| 408 | |
| 409 | // int64_t |
| 410 | Maybe<int64_t> PyUnpackLong(PyObject* py_obj) { |
| 411 | int overflow = -1; |
| 412 | long long val = PyLong_AsLongLongAndOverflow(py_obj, &overflow); |
| 413 | if (val == -1 && PyErr_Occurred()) { return Error::RuntimeError() << "Python exception occurs"; } |
| 414 | if (overflow != 0) { return Error::RuntimeError() << "Overflow when unpacking long"; } |
| 415 | return (int64_t)val; |
| 416 | } |
| 417 | |
| 418 | } // namespace functional |
| 419 | } // namespace one |