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

Skip to content

Commit e2e23ef

Browse files
committed
Remove the UNARY_CONVERT opcode (was used for backticks). Also bumped up the
import MAGIC number.
1 parent 5f5cfd1 commit e2e23ef

12 files changed

Lines changed: 4 additions & 74 deletions

File tree

Doc/lib/libdis.tex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ \subsection{Python Byte Code Instructions}
165165
Implements \code{TOS = not TOS}.
166166
\end{opcodedesc}
167167

168-
\begin{opcodedesc}{UNARY_CONVERT}{}
169-
Implements \code{TOS = `TOS`}.
170-
\end{opcodedesc}
171-
172168
\begin{opcodedesc}{UNARY_INVERT}{}
173169
Implements \code{TOS = \~{}TOS}.
174170
\end{opcodedesc}

Include/Python-ast.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,8 @@ struct _stmt {
186186
enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
187187
IfExp_kind=5, Dict_kind=6, ListComp_kind=7,
188188
GeneratorExp_kind=8, Yield_kind=9, Compare_kind=10,
189-
Call_kind=11, Repr_kind=12, Num_kind=13, Str_kind=14,
190-
Attribute_kind=15, Subscript_kind=16, Name_kind=17,
191-
List_kind=18, Tuple_kind=19};
189+
Call_kind=11, Num_kind=12, Str_kind=13, Attribute_kind=14,
190+
Subscript_kind=15, Name_kind=16, List_kind=17, Tuple_kind=18};
192191
struct _expr {
193192
enum _expr_kind kind;
194193
union {
@@ -252,10 +251,6 @@ struct _expr {
252251
expr_ty kwargs;
253252
} Call;
254253

255-
struct {
256-
expr_ty value;
257-
} Repr;
258-
259254
struct {
260255
object n;
261256
} Num;
@@ -414,7 +409,6 @@ expr_ty Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int
414409
expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
415410
starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
416411
*arena);
417-
expr_ty Repr(expr_ty value, int lineno, int col_offset, PyArena *arena);
418412
expr_ty Num(object n, int lineno, int col_offset, PyArena *arena);
419413
expr_ty Str(string s, int lineno, int col_offset, PyArena *arena);
420414
expr_ty Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int

Include/opcode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ extern "C" {
1818
#define UNARY_POSITIVE 10
1919
#define UNARY_NEGATIVE 11
2020
#define UNARY_NOT 12
21-
#define UNARY_CONVERT 13
2221

2322
#define UNARY_INVERT 15
2423

Lib/compiler/pycodegen.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,9 +1207,6 @@ def visitUnaryInvert(self, node):
12071207
def visitNot(self, node):
12081208
return self.unaryOp(node, 'UNARY_NOT')
12091209

1210-
def visitBackquote(self, node):
1211-
return self.unaryOp(node, 'UNARY_CONVERT')
1212-
12131210
# bit ops
12141211

12151212
def bitOp(self, nodes, op):

Lib/opcode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def jabs_op(name, op):
5454
def_op('UNARY_POSITIVE', 10)
5555
def_op('UNARY_NEGATIVE', 11)
5656
def_op('UNARY_NOT', 12)
57-
def_op('UNARY_CONVERT', 13)
5857

5958
def_op('UNARY_INVERT', 15)
6059

Parser/Python.asdl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ module Python version "$Revision$"
6565
| Compare(expr left, cmpop* ops, expr* comparators)
6666
| Call(expr func, expr* args, keyword* keywords,
6767
expr? starargs, expr? kwargs)
68-
| Repr(expr value)
6968
| Num(object n) -- a number as a PyObject.
7069
| Str(string s) -- need to specify raw, unicode, etc?
7170
-- other literals? bools?

Python/Python-ast.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ static char *Call_fields[]={
206206
"starargs",
207207
"kwargs",
208208
};
209-
static PyTypeObject *Repr_type;
210-
static char *Repr_fields[]={
211-
"value",
212-
};
213209
static PyTypeObject *Num_type;
214210
static char *Num_fields[]={
215211
"n",
@@ -532,8 +528,6 @@ static int init_types(void)
532528
if (!Compare_type) return 0;
533529
Call_type = make_type("Call", expr_type, Call_fields, 5);
534530
if (!Call_type) return 0;
535-
Repr_type = make_type("Repr", expr_type, Repr_fields, 1);
536-
if (!Repr_type) return 0;
537531
Num_type = make_type("Num", expr_type, Num_fields, 1);
538532
if (!Num_type) return 0;
539533
Str_type = make_type("Str", expr_type, Str_fields, 1);
@@ -1552,27 +1546,6 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
15521546
return p;
15531547
}
15541548

1555-
expr_ty
1556-
Repr(expr_ty value, int lineno, int col_offset, PyArena *arena)
1557-
{
1558-
expr_ty p;
1559-
if (!value) {
1560-
PyErr_SetString(PyExc_ValueError,
1561-
"field value is required for Repr");
1562-
return NULL;
1563-
}
1564-
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1565-
if (!p) {
1566-
PyErr_NoMemory();
1567-
return NULL;
1568-
}
1569-
p->kind = Repr_kind;
1570-
p->v.Repr.value = value;
1571-
p->lineno = lineno;
1572-
p->col_offset = col_offset;
1573-
return p;
1574-
}
1575-
15761549
expr_ty
15771550
Num(object n, int lineno, int col_offset, PyArena *arena)
15781551
{
@@ -2544,15 +2517,6 @@ ast2obj_expr(void* _o)
25442517
goto failed;
25452518
Py_DECREF(value);
25462519
break;
2547-
case Repr_kind:
2548-
result = PyType_GenericNew(Repr_type, NULL, NULL);
2549-
if (!result) goto failed;
2550-
value = ast2obj_expr(o->v.Repr.value);
2551-
if (!value) goto failed;
2552-
if (PyObject_SetAttrString(result, "value", value) == -1)
2553-
goto failed;
2554-
Py_DECREF(value);
2555-
break;
25562520
case Num_kind:
25572521
result = PyType_GenericNew(Num_type, NULL, NULL);
25582522
if (!result) goto failed;
@@ -3113,7 +3077,6 @@ init_ast(void)
31133077
if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0)
31143078
return;
31153079
if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return;
3116-
if (PyDict_SetItemString(d, "Repr", (PyObject*)Repr_type) < 0) return;
31173080
if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return;
31183081
if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return;
31193082
if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) <

Python/ast.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,6 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n)
401401
case Compare_kind:
402402
expr_name = "comparison";
403403
break;
404-
case Repr_kind:
405-
expr_name = "repr";
406-
break;
407404
case IfExp_kind:
408405
expr_name = "conditional expression";
409406
break;

Python/ceval.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,14 +1040,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
10401040
STACKADJ(-1);
10411041
break;
10421042

1043-
case UNARY_CONVERT:
1044-
v = TOP();
1045-
x = PyObject_Repr(v);
1046-
Py_DECREF(v);
1047-
SET_TOP(x);
1048-
if (x != NULL) continue;
1049-
break;
1050-
10511043
case UNARY_INVERT:
10521044
v = TOP();
10531045
x = PyNumber_Invert(v);

Python/import.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
6565
Python 2.5c1: 62121 (fix wrong lnotab with for loops and
6666
storing constants that should have been removed)
6767
Python 3000: 3000
68+
3010 (removed UNARY_CONVERT)
6869
.
6970
*/
70-
#define MAGIC (3000 | ((long)'\r'<<16) | ((long)'\n'<<24))
71+
#define MAGIC (3010 | ((long)'\r'<<16) | ((long)'\n'<<24))
7172

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

0 commit comments

Comments
 (0)