forked from bartvdbraak/blender
add local _PyLong_AsInt() needed for python older then 3.3.2
This commit is contained in:
parent
992902cee0
commit
6d5024828b
@ -887,3 +887,19 @@ PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* compat only */
|
||||||
|
#if PY_VERSION_HEX < 0x03030200
|
||||||
|
int
|
||||||
|
_PyLong_AsInt(PyObject *obj)
|
||||||
|
{
|
||||||
|
int overflow;
|
||||||
|
long result = PyLong_AsLongAndOverflow(obj, &overflow);
|
||||||
|
if (overflow || result > INT_MAX || result < INT_MIN) {
|
||||||
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
|
"Python int too large to convert to C int");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return (int)result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -72,4 +72,8 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int
|
|||||||
int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix);
|
int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix);
|
||||||
PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag);
|
PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag);
|
||||||
|
|
||||||
|
#if PY_VERSION_HEX < 0x03030200
|
||||||
|
int _PyLong_AsInt(PyObject *obj);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __PY_CAPI_UTILS_H__ */
|
#endif /* __PY_CAPI_UTILS_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user