File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change 20
20
extern "C" {
21
21
#endif
22
22
23
- /*
24
- * Macros to protect CRT calls against instant termination when passed an
25
- * invalid parameter (https://bugs.python.org/issue23524).
26
- */
23
+ /* Python13 removes _PyLong_AsInt */
24
+ static inline int
25
+ Npy__PyLong_AsInt (PyObject * obj )
26
+ {
27
+ int overflow ;
28
+ long result = PyLong_AsLongAndOverflow (obj , & overflow );
29
+
30
+ /* INT_MAX and INT_MIN are defined in Python.h */
31
+ if (overflow || result > INT_MAX || result < INT_MIN ) {
32
+ /* XXX: could be cute and give a different
33
+ message for overflow == -1 */
34
+ PyErr_SetString (PyExc_OverflowError ,
35
+ "Python int too large to convert to C int" );
36
+ return -1 ;
37
+ }
38
+ return (int )result ;
39
+ }
40
+
27
41
#if defined _MSC_VER && _MSC_VER >= 1900
28
42
29
43
#include <stdlib.h>
30
44
45
+ /*
46
+ * Macros to protect CRT calls against instant termination when passed an
47
+ * invalid parameter (https://bugs.python.org/issue23524).
48
+ */
31
49
extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler ;
32
50
#define NPY_BEGIN_SUPPRESS_IPH { _invalid_parameter_handler _Py_old_handler = \
33
51
_set_thread_local_invalid_parameter_handler(_Py_silent_invalid_parameter_handler);
@@ -40,7 +58,6 @@ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler;
40
58
41
59
#endif /* _MSC_VER >= 1900 */
42
60
43
-
44
61
/*
45
62
* PyFile_* compatibility
46
63
*/
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