Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fea59e7

Browse files
committed
The opcode FOR_LOOP no longer exists.
1 parent efb9097 commit fea59e7

4 files changed

Lines changed: 3 additions & 40 deletions

File tree

Doc/lib/libdis.tex

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,9 @@ \subsection{Python Byte Code Instructions}
556556
popped, and the byte code counter is incremented by \var{delta}.
557557
\end{opcodedesc}
558558

559-
\begin{opcodedesc}{FOR_LOOP}{delta}
560-
This opcode is obsolete.
561-
%Iterate over a sequence. TOS is the current index, TOS1 the sequence.
562-
%First, the next element is computed. If the sequence is exhausted,
563-
%increment byte code counter by \var{delta}. Otherwise, push the
564-
%sequence, the incremented counter, and the current item onto the stack.
565-
\end{opcodedesc}
559+
%\begin{opcodedesc}{FOR_LOOP}{delta}
560+
%This opcode is obsolete.
561+
%\end{opcodedesc}
566562

567563
%\begin{opcodedesc}{LOAD_LOCAL}{namei}
568564
%This opcode is obsolete.

Include/opcode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ extern "C" {
107107
#define JUMP_IF_FALSE 111 /* "" */
108108
#define JUMP_IF_TRUE 112 /* "" */
109109
#define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */
110-
#define FOR_LOOP 114 /* Number of bytes to skip */
111110

112111
#define LOAD_GLOBAL 116 /* Index in name list */
113112

Lib/dis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ def jabs_op(name, op):
262262
jrel_op('JUMP_IF_FALSE', 111) # ""
263263
jrel_op('JUMP_IF_TRUE', 112) # ""
264264
jabs_op('JUMP_ABSOLUTE', 113) # Target byte offset from beginning of code
265-
jrel_op('FOR_LOOP', 114) # Number of bytes to skip
266265

267266
name_op('LOAD_GLOBAL', 116) # Index in name list
268267

Python/ceval.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,37 +1942,6 @@ eval_frame(PyFrameObject *f)
19421942
}
19431943
break;
19441944

1945-
case FOR_LOOP:
1946-
/* for v in s: ...
1947-
On entry: stack contains s, i.
1948-
On exit: stack contains s, i+1, s[i];
1949-
but if loop exhausted:
1950-
s, i are popped, and we jump */
1951-
w = POP(); /* Loop index */
1952-
v = POP(); /* Sequence object */
1953-
u = loop_subscript(v, w);
1954-
if (u != NULL) {
1955-
PUSH(v);
1956-
x = PyInt_FromLong(PyInt_AsLong(w)+1);
1957-
PUSH(x);
1958-
Py_DECREF(w);
1959-
PUSH(u);
1960-
if (x != NULL) continue;
1961-
}
1962-
else {
1963-
Py_DECREF(v);
1964-
Py_DECREF(w);
1965-
/* A NULL can mean "s exhausted"
1966-
but also an error: */
1967-
if (PyErr_Occurred())
1968-
why = WHY_EXCEPTION;
1969-
else {
1970-
JUMPBY(oparg);
1971-
continue;
1972-
}
1973-
}
1974-
break;
1975-
19761945
case SETUP_LOOP:
19771946
case SETUP_EXCEPT:
19781947
case SETUP_FINALLY:

0 commit comments

Comments
 (0)