@@ -1417,7 +1417,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1417
1417
numargs = PyTuple_Size (args );
1418
1418
if (numargs == 2 ) {
1419
1419
if (a1 != Py_None ) {
1420
- stop = PyLong_AsSsize_t (a1 );
1420
+ stop = PyNumber_AsSsize_t (a1 , PyExc_OverflowError );
1421
1421
if (stop == -1 ) {
1422
1422
if (PyErr_Occurred ())
1423
1423
PyErr_Clear ();
@@ -1429,11 +1429,11 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1429
1429
}
1430
1430
} else {
1431
1431
if (a1 != Py_None )
1432
- start = PyLong_AsSsize_t (a1 );
1432
+ start = PyNumber_AsSsize_t (a1 , PyExc_OverflowError );
1433
1433
if (start == -1 && PyErr_Occurred ())
1434
1434
PyErr_Clear ();
1435
1435
if (a2 != Py_None ) {
1436
- stop = PyLong_AsSsize_t (a2 );
1436
+ stop = PyNumber_AsSsize_t (a2 , PyExc_OverflowError );
1437
1437
if (stop == -1 ) {
1438
1438
if (PyErr_Occurred ())
1439
1439
PyErr_Clear ();
@@ -1453,7 +1453,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1453
1453
1454
1454
if (a3 != NULL ) {
1455
1455
if (a3 != Py_None )
1456
- step = PyLong_AsSsize_t (a3 );
1456
+ step = PyNumber_AsSsize_t (a3 , PyExc_OverflowError );
1457
1457
if (step == -1 && PyErr_Occurred ())
1458
1458
PyErr_Clear ();
1459
1459
}
@@ -1573,7 +1573,7 @@ islice_reduce(isliceobject *lz)
1573
1573
static PyObject *
1574
1574
islice_setstate (isliceobject * lz , PyObject * state )
1575
1575
{
1576
- Py_ssize_t cnt = PyLong_AsSsize_t (state );
1576
+ Py_ssize_t cnt = PyNumber_AsSsize_t (state , PyExc_OverflowError );
1577
1577
1578
1578
if (cnt == -1 && PyErr_Occurred ())
1579
1579
return NULL ;
@@ -2265,7 +2265,7 @@ product_setstate(productobject *lz, PyObject *state)
2265
2265
for (i = 0 ; i < n ; i ++ )
2266
2266
{
2267
2267
PyObject * indexObject = PyTuple_GET_ITEM (state , i );
2268
- Py_ssize_t index = PyLong_AsSsize_t (indexObject );
2268
+ Py_ssize_t index = PyNumber_AsSsize_t (indexObject , PyExc_OverflowError );
2269
2269
PyObject * pool ;
2270
2270
Py_ssize_t poolsize ;
2271
2271
if (index < 0 && PyErr_Occurred ())
@@ -2592,7 +2592,7 @@ combinations_setstate(combinationsobject *lz, PyObject *state)
2592
2592
for (i = 0 ; i < lz -> r ; i ++ ) {
2593
2593
Py_ssize_t max ;
2594
2594
PyObject * indexObject = PyTuple_GET_ITEM (state , i );
2595
- Py_ssize_t index = PyLong_AsSsize_t (indexObject );
2595
+ Py_ssize_t index = PyNumber_AsSsize_t (indexObject , PyExc_OverflowError );
2596
2596
2597
2597
if (index == -1 && PyErr_Occurred ())
2598
2598
return NULL ; /* not an integer */
@@ -2925,7 +2925,7 @@ cwr_setstate(cwrobject *lz, PyObject *state)
2925
2925
n = PyTuple_GET_SIZE (lz -> pool );
2926
2926
for (i = 0 ; i < lz -> r ; i ++ ) {
2927
2927
PyObject * indexObject = PyTuple_GET_ITEM (state , i );
2928
- Py_ssize_t index = PyLong_AsSsize_t (indexObject );
2928
+ Py_ssize_t index = PyNumber_AsSsize_t (indexObject , PyExc_OverflowError );
2929
2929
2930
2930
if (index < 0 && PyErr_Occurred ())
2931
2931
return NULL ; /* not an integer */
@@ -3072,11 +3072,11 @@ permutations_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3072
3072
3073
3073
r = n ;
3074
3074
if (robj != Py_None ) {
3075
- if (!PyLong_Check (robj )) {
3076
- PyErr_SetString (PyExc_TypeError , "Expected int as r" );
3075
+ if (!PyNumber_Check (robj )) {
3076
+ PyErr_SetString (PyExc_TypeError , "Expected number as r" );
3077
3077
goto error ;
3078
3078
}
3079
- r = PyLong_AsSsize_t (robj );
3079
+ r = PyNumber_AsSsize_t (robj , PyExc_OverflowError );
3080
3080
if (r == -1 && PyErr_Occurred ())
3081
3081
goto error ;
3082
3082
}
@@ -3307,7 +3307,7 @@ permutations_setstate(permutationsobject *po, PyObject *state)
3307
3307
3308
3308
for (i = 0 ; i < n ; i ++ ) {
3309
3309
PyObject * indexObject = PyTuple_GET_ITEM (indices , i );
3310
- Py_ssize_t index = PyLong_AsSsize_t (indexObject );
3310
+ Py_ssize_t index = PyNumber_AsSsize_t (indexObject , PyExc_OverflowError );
3311
3311
if (index < 0 && PyErr_Occurred ())
3312
3312
return NULL ; /* not an integer */
3313
3313
/* clamp the index */
@@ -3320,7 +3320,7 @@ permutations_setstate(permutationsobject *po, PyObject *state)
3320
3320
3321
3321
for (i = 0 ; i < po -> r ; i ++ ) {
3322
3322
PyObject * indexObject = PyTuple_GET_ITEM (cycles , i );
3323
- Py_ssize_t index = PyLong_AsSsize_t (indexObject );
3323
+ Py_ssize_t index = PyNumber_AsSsize_t (indexObject , PyExc_OverflowError );
3324
3324
if (index < 0 && PyErr_Occurred ())
3325
3325
return NULL ; /* not an integer */
3326
3326
if (index < 1 )
0 commit comments