Skip to content

Commit 38c9de5

Browse files
committed
review comments
1 parent bdd742c commit 38c9de5

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

Include/internal/pycore_sliceobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern "C" {
1212
/* runtime lifecycle */
1313

1414
PyAPI_FUNC(PyObject *)
15-
_PyBuildSlice_ConsumeRefs(PyObject *start, PyObject *stop);
15+
_PyBuildSlice_ConsumeRefs(PyObject *start, PyObject *stop, PyObject *step);
1616

1717
#ifdef __cplusplus
1818
}

Modules/_testinternalcapi/test_cases.c.h

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

Objects/sliceobject.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ PyObject _Py_EllipsisObject = _PyObject_HEAD_INIT(&PyEllipsis_Type);
117117
index is present.
118118
*/
119119

120-
static PySliceObject *
121-
_PyBuildSlice_Consume3(PyObject *start, PyObject *stop, PyObject *step)
120+
PyObject *
121+
_PyBuildSlice_ConsumeRefs(PyObject *start, PyObject *stop, PyObject *step)
122122
{
123123
assert(start != NULL && stop != NULL && step != NULL);
124124
PySliceObject *obj = _Py_FREELIST_POP(PySliceObject, slices);
@@ -134,7 +134,7 @@ _PyBuildSlice_Consume3(PyObject *start, PyObject *stop, PyObject *step)
134134
obj->step = step;
135135

136136
_PyObject_GC_TRACK(obj);
137-
return obj;
137+
return (PyObject *)obj;
138138
error:
139139
Py_DECREF(start);
140140
Py_DECREF(stop);
@@ -154,17 +154,10 @@ PySlice_New(PyObject *start, PyObject *stop, PyObject *step)
154154
if (stop == NULL) {
155155
stop = Py_None;
156156
}
157-
return (PyObject *)_PyBuildSlice_Consume3(Py_NewRef(start),
157+
return _PyBuildSlice_ConsumeRefs(Py_NewRef(start),
158158
Py_NewRef(stop), Py_NewRef(step));
159159
}
160160

161-
PyObject *
162-
_PyBuildSlice_ConsumeRefs(PyObject *start, PyObject *stop)
163-
{
164-
assert(start != NULL && stop != NULL);
165-
return (PyObject *)_PyBuildSlice_Consume3(start, stop, Py_None);
166-
}
167-
168161
PyObject *
169162
_PySlice_FromIndices(Py_ssize_t istart, Py_ssize_t istop)
170163
{
@@ -178,7 +171,7 @@ _PySlice_FromIndices(Py_ssize_t istart, Py_ssize_t istop)
178171
return NULL;
179172
}
180173

181-
slice = _PyBuildSlice_ConsumeRefs(start, end);
174+
slice = _PyBuildSlice_ConsumeRefs(start, end, Py_None);
182175
return slice;
183176
}
184177

Python/bytecodes.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,8 @@ dummy_func(
867867

868868
op(_BINARY_SLICE, (container, start, stop -- res)) {
869869
PyObject *slice = _PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
870-
PyStackRef_AsPyObjectSteal(stop));
870+
PyStackRef_AsPyObjectSteal(stop),
871+
Py_None);
871872
PyObject *res_o;
872873
// Can't use ERROR_IF() here, because we haven't
873874
// DECREF'ed container yet, and we still own slice.
@@ -894,7 +895,8 @@ dummy_func(
894895

895896
op(_STORE_SLICE, (v, container, start, stop -- )) {
896897
PyObject *slice = _PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
897-
PyStackRef_AsPyObjectSteal(stop));
898+
PyStackRef_AsPyObjectSteal(stop),
899+
Py_None);
898900
int err;
899901
if (slice == NULL) {
900902
err = 1;

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)