MCPcopy Create free account
hub / github.com/numpy/numpy / Npy__PyLong_AsInt

Function Npy__PyLong_AsInt

numpy/core/include/numpy/npy_3kcompat.h:39–54  ·  view source on GitHub ↗

* This is a renamed copy of the Python non-limited API function _PyLong_AsInt. It is * included here because it is missing from the PyPy API. It completes the PyLong_As* * group of functions and can be useful in replacing PyInt_Check. */

Source from the content-addressed store, hash-verified

37 * group of functions and can be useful in replacing PyInt_Check.
38 */
39static inline int
40Npy__PyLong_AsInt(PyObject *obj)
41{
42 int overflow;
43 long result = PyLong_AsLongAndOverflow(obj, &overflow);
44
45 /* INT_MAX and INT_MIN are defined in Python.h */
46 if (overflow || result > INT_MAX || result < INT_MIN) {
47 /* XXX: could be cute and give a different
48 message for overflow == -1 */
49 PyErr_SetString(PyExc_OverflowError,
50 "Python int too large to convert to C int");
51 return -1;
52 }
53 return (int)result;
54}
55
56
57#if defined(NPY_PY3K)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected