8000 BUILD_SLICE · python/cpython@b8745d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b8745d7

Browse files
committed
BUILD_SLICE
1 parent 15b0931 commit b8745d7

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed
< 10000 div class="Diff-module__diffHeaderWrapper--rsdD4" style="--header-sticky-offset:0px">

Python/bytecodes.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,22 +3037,12 @@ dummy_func(
30373037
goto resume_frame;
30383038
}
30393039

3040-
// error: BUILD_SLICE has irregular stack effect
3041-
inst(BUILD_SLICE) {
3042-
PyObject *start, *stop, *step, *slice;
3043-
if (oparg == 3)
3044-
step = POP();
3045-
else
3046-
step = NULL;
3047-
stop = POP();
3048-
start = TOP();
3040+
inst(BUILD_SLICE, (start, stop, step if (oparg == 3) -- slice)) {
30493041
slice = PySlice_New(start, stop, step);
30503042
Py_DECREF(start);
30513043
Py_DECREF(stop);
30523044
Py_XDECREF(step);
3053-
SET_TOP(slice);
3054-
if (slice == NULL)
3055-
goto error;
3045+
ERROR_IF(slice == NULL, error);
30563046
}
30573047

30583048
// error: FORMAT_VALUE has irregular stack effect

Python/generated_cases.c.h

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

Python/opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
329329
case RETURN_GENERATOR:
330330
return -1;
331331
case BUILD_SLICE:
332-
return -1;
332+
return ((oparg == 3) ? 1 : 0) + 2;
333333
case FORMAT_VALUE:
334334
return -1;
335335
case COPY:
@@ -675,7 +675,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
675675
case RETURN_GENERATOR:
676676
return -1;
677677
case BUILD_SLICE:
678-
return -1;
678+
return 1;
679679
case FORMAT_VALUE:
680680
return -1;
681681
case COPY:

0 commit comments

Comments
 (0)
0