diff options
author | Will Roberts <wildwilhelm@gmail.com> | 2017-06-08 06:03:04 (GMT) |
---|---|---|
committer | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2017-06-08 06:03:04 (GMT) |
commit | 0ecdc525146ecec9d1549ebf59404c769637a512 (patch) | |
tree | 2b37e56ef0ce6ac198d6ffc622da6f01c91ad4ef /Modules/itertoolsmodule.c | |
parent | 5edf827c8052958b9d293f75ce8d93b66c1d58da (diff) | |
download | cpython-0ecdc525146ecec9d1549ebf59404c769637a512.zip cpython-0ecdc525146ecec9d1549ebf59404c769637a512.tar.gz cpython-0ecdc525146ecec9d1549ebf59404c769637a512.tar.bz2 |
bpo-30537: use PyNumber in itertools.islice instead of PyLong (#1918)
* bpo-30537: use PyNumber in itertools instead of PyLong
* bpo-30537: revert changes except to islice_new
* bpo-30537: test itertools.islice and add entry to Misc/NEWS
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index fac5b29..ee7bb66 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -1417,7 +1417,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds) numargs = PyTuple_Size(args); if (numargs == 2) { if (a1 != Py_None) { - stop = PyLong_AsSsize_t(a1); + stop = PyNumber_AsSsize_t(a1, PyExc_OverflowError); if (stop == -1) { if (PyErr_Occurred()) PyErr_Clear(); @@ -1429,11 +1429,11 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } } else { if (a1 != Py_None) - start = PyLong_AsSsize_t(a1); + start = PyNumber_AsSsize_t(a1, PyExc_OverflowError); if (start == -1 && PyErr_Occurred()) PyErr_Clear(); if (a2 != Py_None) { - stop = PyLong_AsSsize_t(a2); + stop = PyNumber_AsSsize_t(a2, PyExc_OverflowError); if (stop == -1) { if (PyErr_Occurred()) PyErr_Clear(); @@ -1453,7 +1453,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (a3 != NULL) { if (a3 != Py_None) - step = PyLong_AsSsize_t(a3); + step = PyNumber_AsSsize_t(a3, PyExc_OverflowError); if (step == -1 && PyErr_Occurred()) PyErr_Clear(); } |