Skip to content

Commit b47e3fc

Browse files
committed
move AdjustIndices to _UNPACK_INDICES
1 parent 3dd3f3a commit b47e3fc

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

Python/bytecodes.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,12 @@ dummy_func(
892892
PyStackRef_CLOSE(container);
893893
ERROR_IF(true);
894894
}
895+
Py_ssize_t len = PyObject_Length(PyStackRef_AsPyObjectBorrow(container));
896+
if (len < 0) {
897+
PyStackRef_CLOSE(container);
898+
ERROR_IF(true);
899+
}
900+
PySlice_AdjustIndices(len, &istart, &istop, 1);
895901
sta = PyStackRef_TagInt((intptr_t)istart);
896902
sto = PyStackRef_TagInt((intptr_t)istop);
897903
}
@@ -903,7 +909,6 @@ dummy_func(
903909
Py_ssize_t istop = PyStackRef_UntagInt(stop);
904910
DEAD(start);
905911
DEAD(stop);
906-
PySlice_AdjustIndices(PyList_GET_SIZE(container_o), &istart, &istop, 1);
907912
PyObject *res_o = PyList_GetSlice(container_o, istart, istop);
908913
PyStackRef_CLOSE(container);
909914
ERROR_IF(res_o == NULL);
@@ -917,7 +922,6 @@ dummy_func(
917922
Py_ssize_t istop = PyStackRef_UntagInt(stop);
918923
DEAD(start);
919924
DEAD(stop);
920-
PySlice_AdjustIndices(PyTuple_GET_SIZE(container_o), &istart, &istop, 1);
921925
PyObject *res_o = PyTuple_GetSlice(container_o, istart, istop);
922926
PyStackRef_CLOSE(container);
923927
ERROR_IF(res_o == NULL);
@@ -931,7 +935,6 @@ dummy_func(
931935
Py_ssize_t istop = PyStackRef_UntagInt(stop);
932936
DEAD(start);
933937
DEAD(stop);
934-
PySlice_AdjustIndices(PyUnicode_GET_LENGTH(container_o), &istart, &istop, 1);
935938
PyObject *res_o = PyUnicode_Substring(container_o, istart, istop);
936939
PyStackRef_CLOSE(container);
937940
ERROR_IF(res_o == NULL);

Python/executor_cases.c.h

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)