| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,7 +75,7 @@ Slice Objects | |||
| 75 | 75 | Extract the start, stop and step data members from a slice object as | |
| 76 | 76 | C integers. Silently reduce values larger than ``PY_SSIZE_T_MAX`` to | |
| 77 | 77 | ``PY_SSIZE_T_MAX``, silently boost the start and stop values less than | |
| 78 | - ``-PY_SSIZE_T_MAX-1`` to ``-PY_SSIZE_T_MAX-1``, and silently boost the step | ||
| 78 | + ``PY_SSIZE_T_MIN`` to ``PY_SSIZE_T_MIN``, and silently boost the step | ||
| 79 | 79 | values less than ``-PY_SSIZE_T_MAX`` to ``-PY_SSIZE_T_MAX``. | |
| 80 | 80 | ||
| 81 | 81 | Return ``-1`` on error, ``0`` on success. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -197,6 +197,8 @@ PySlice_Unpack(PyObject *_r, | |||
| 197 | 197 | PySliceObject *r = (PySliceObject*)_r; | |
| 198 | 198 | /* this is harder to get right than you might think */ | |
| 199 | 199 | ||
| 200 | + Py_BUILD_ASSERT(PY_SSIZE_T_MIN + 1 <= -PY_SSIZE_T_MAX); | ||
| 201 | + | ||
| 200 | 202 | if (r->step == Py_None) { | |
| 201 | 203 | *step = 1; | |
| 202 | 204 | } | |
@@ -217,14 +219,14 @@ PySlice_Unpack(PyObject *_r, | |||
| 217 | 219 | } | |
| 218 | 220 | ||
| 219 | 221 | if (r->start == Py_None) { | |
| 220 | - *start = *step < 0 ? PY_SSIZE_T_MAX-1 : 0;; | ||
| 222 | + *start = *step < 0 ? PY_SSIZE_T_MAX : 0; | ||
| 221 | 223 | } | |
| 222 | 224 | else { | |
| 223 | 225 | if (!_PyEval_SliceIndex(r->start, start)) return -1; | |
| 224 | 226 | } | |
| 225 | 227 | ||
| 226 | 228 | if (r->stop == Py_None) { | |
| 227 | - *stop = *step < 0 ? -PY_SSIZE_T_MAX : PY_SSIZE_T_MAX; | ||
| 229 | + *stop = *step < 0 ? PY_SSIZE_T_MIN : PY_SSIZE_T_MAX; | ||
| 228 | 230 | } | |
| 229 | 231 | else { | |
| 230 | 232 | if (!_PyEval_SliceIndex(r->stop, stop)) return -1; | |
@@ -258,7 +260,7 @@ PySlice_AdjustIndices(Py_ssize_t length, | |||
| 258 | 260 | *stop = (step < 0) ? -1 : 0; | |
| 259 | 261 | } | |
| 260 | 262 | } | |
| 261 | - else if (*stop >= length) { | ||
| 263 | + else if (*stop >= length) { | ||
| 262 | 264 | *stop = (step < 0) ? length - 1 : length; | |
| 263 | 265 | } | |
| 264 | 266 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4889,7 +4889,7 @@ do_call_core(PyObject *func, PyObject *callargs, PyObject *kwdict) | |||
| 4889 | 4889 | /* Extract a slice index from a PyLong or an object with the | |
| 4890 | 4890 | nb_index slot defined, and store in *pi. | |
| 4891 | 4891 | Silently reduce values larger than PY_SSIZE_T_MAX to PY_SSIZE_T_MAX, | |
| 4892 | - and silently boost values less than -PY_SSIZE_T_MAX-1 to -PY_SSIZE_T_MAX-1. | ||
| 4892 | + and silently boost values less than PY_SSIZE_T_MIN to PY_SSIZE_T_MIN. | ||
| 4893 | 4893 | Return 0 on error, 1 on success. | |
| 4894 | 4894 | */ | |
| 4895 | 4895 | int | |
| Back | FazBrowse Home | New Git URL |
0 commit comments