File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,25 @@ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler;
40
40
41
41
#endif /* _MSC_VER >= 1900 */
42
42
43
+ /* Python13 removes _PyLong_AsInt */
44
+ static inline int
45
+ Npy__PyLong_AsInt (PyObject * obj )
46
+ {
47
+ int overflow ;
48
+ long result = PyLong_AsLongAndOverflow (obj , & overflow );
49
+
50
+ /* INT_MAX and INT_MIN are defined in Python.h */
51
+ if (overflow || result > INT_MAX || result < INT_MIN ) {
52
+ /* XXX: could be cute and give a different
53
+ * message for overflow == -1 */
54
+ PyErr_SetString (PyExc_OverflowError ,
55
+ "Python int too large to convert to C int" );
56
+ return -1 ;
57
+ }
58
+ return (int )result ;
59
+ }
60
+
61
+
43
62
44
63
/*
45
64
* PyFile_* compatibility
Original file line number Diff line number Diff line change 878
878
PyObject* tmp = NULL;
879
879
880
880
if (PyLong_Check(obj)) {
881
- *v = _PyLong_AsInt (obj);
881
+ *v = Npy__PyLong_AsInt (obj);
882
882
return !(*v == -1 && PyErr_Occurred());
883
883
}
884
884
885
885
tmp = PyNumber_Long(obj);
886
886
if (tmp) {
887
- *v = _PyLong_AsInt (tmp);
887
+ *v = Npy__PyLong_AsInt (tmp);
888
888
Py_DECREF(tmp);
889
889
return !(*v == -1 && PyErr_Occurred());
890
890
}
You can’t perform that action at this time.
0 commit comments