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

Skip to content

Commit 0be5aab

Browse files
committed
Merge UNPACK_LIST and UNPACK_TUPLE into a single UNPACK_SEQUENCE, since they
did the same anyway. I'm not sure what to do with Tools/compiler/compiler/* -- that isn't part of distutils, is it ? Should it try to be compatible with old bytecode version ?
1 parent a8d7341 commit 0be5aab

6 files changed

Lines changed: 15 additions & 29 deletions

File tree

Doc/lib/libdis.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ \subsection{Python Byte Code Instructions}
337337
\member{co_names} attribute of the code object.
338338
\end{opcodedesc}
339339

340-
\begin{opcodedesc}{UNPACK_TUPLE}{count}
340+
\begin{opcodedesc}{UNPACK_SEQUENCE}{count}
341341
Unpacks TOS into \var{count} individual values, which are put onto
342342
the stack right-to-left.
343343
\end{opcodedesc}
344344

345-
\begin{opcodedesc}{UNPACK_LIST}{count}
346-
Unpacks TOS into \var{count} individual values.
347-
\end{opcodedesc}
345+
%\begin{opcodedesc}{UNPACK_LIST}{count}
346+
%This opcode is obsolete.
347+
%\end{opcodedesc}
348348

349349
%\begin{opcodedesc}{UNPACK_ARG}{count}
350350
%This opcode is obsolete.

Include/opcode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7676

7777
#define STORE_NAME 90 /* Index in name list */
7878
#define DELETE_NAME 91 /* "" */
79-
#define UNPACK_TUPLE 92 /* Number of tuple items */
80-
#define UNPACK_LIST 93 /* Number of list items */
79+
#define UNPACK_SEQUENCE 92 /* Number of sequence items */
80+
8181
#define STORE_ATTR 95 /* Index in name list */
8282
#define DELETE_ATTR 96 /* "" */
8383
#define STORE_GLOBAL 97 /* "" */

Lib/dis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ def jabs_op(name, op):
206206

207207
name_op('STORE_NAME', 90) # Index in name list
208208
name_op('DELETE_NAME', 91) # ""
209-
def_op('UNPACK_TUPLE', 92) # Number of tuple items
210-
def_op('UNPACK_LIST', 93) # Number of list items
209+
def_op('UNPACK_SEQUENCE', 92) # Number of tuple items
210+
211211
name_op('STORE_ATTR', 95) # Index in name list
212212
name_op('DELETE_ATTR', 96) # ""
213213
name_op('STORE_GLOBAL', 97) # ""

Python/ceval.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
11651165
default: switch (opcode) {
11661166
#endif
11671167

1168-
case UNPACK_TUPLE:
1169-
case UNPACK_LIST:
1168+
case UNPACK_SEQUENCE:
11701169
v = POP();
11711170
if (PyTuple_Check(v)) {
11721171
if (PyTuple_Size(v) != oparg) {

Python/compile.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,27 +1729,14 @@ com_assign_trailer(struct compiling *c, node *n, int assigning)
17291729
}
17301730

17311731
static void
1732-
com_assign_tuple(struct compiling *c, node *n, int assigning)
1732+
com_assign_sequence(struct compiling *c, node *n, int assigning)
17331733
{
17341734
int i;
17351735
if (TYPE(n) != testlist)
17361736
REQ(n, exprlist);
17371737
if (assigning) {
17381738
i = (NCH(n)+1)/2;
1739-
com_addoparg(c, UNPACK_TUPLE, i);
1740-
com_push(c, i-1);
1741-
}
1742-
for (i = 0; i < NCH(n); i += 2)
1743-
com_assign(c, CHILD(n, i), assigning);
1744-
}
1745-
1746-
static void
1747-
com_assign_list(struct compiling *c, node *n, int assigning)
1748-
{
1749-
int i;
1750-
if (assigning) {
1751-
i = (NCH(n)+1)/2;
1752-
com_addoparg(c, UNPACK_LIST, i);
1739+
com_addoparg(c, UNPACK_SEQUENCE, i);
17531740
com_push(c, i-1);
17541741
}
17551742
for (i = 0; i < NCH(n); i += 2)
@@ -1775,7 +1762,7 @@ com_assign(struct compiling *c, node *n, int assigning)
17751762
case exprlist:
17761763
case testlist:
17771764
if (NCH(n) > 1) {
1778-
com_assign_tuple(c, n, assigning);
1765+
com_assign_sequence(c, n, assigning);
17791766
return;
17801767
}
17811768
n = CHILD(n, 0);
@@ -1843,7 +1830,7 @@ com_assign(struct compiling *c, node *n, int assigning)
18431830
"can't assign to []");
18441831
return;
18451832
}
1846-
com_assign_list(c, n, assigning);
1833+
com_assign_sequence(c, n, assigning);
18471834
return;
18481835
case NAME:
18491836
com_assign_name(c, CHILD(n, 0), assigning);
@@ -2869,7 +2856,7 @@ com_fplist(struct compiling *c, node *n)
28692856
}
28702857
else {
28712858
int i = (NCH(n)+1)/2;
2872-
com_addoparg(c, UNPACK_TUPLE, i);
2859+
com_addoparg(c, UNPACK_SEQUENCE, i);
28732860
com_push(c, i-1);
28742861
for (i = 0; i < NCH(n); i += 2)
28752862
com_fpdef(c, CHILD(n, i));

Python/import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
6666
/* XXX Perhaps the magic number should be frozen and a version field
6767
added to the .pyc file header? */
6868
/* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */
69-
#define MAGIC (50428 | ((long)'\r'<<16) | ((long)'\n'<<24))
69+
#define MAGIC (50811 | ((long)'\r'<<16) | ((long)'\n'<<24))
7070

7171
/* Magic word as global; note that _PyImport_Init() can change the
7272
value of this global to accommodate for alterations of how the

0 commit comments

Comments
 (0)