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

Skip to content

Commit cf588f6

Browse files
committed
Remove support for backticks from the grammar and compiler.
Still need to remove traces of the UNARY_CONVERT opcode.
1 parent 8b6de13 commit cf588f6

7 files changed

Lines changed: 86 additions & 154 deletions

File tree

Doc/ref/ref5.tex

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -268,49 +268,6 @@ \subsection{Dictionary displays\label{dict}}
268268
\indexii{immutable}{object}
269269

270270

271-
\subsection{String conversions\label{string-conversions}}
272-
\indexii{string}{conversion}
273-
\indexii{reverse}{quotes}
274-
\indexii{backward}{quotes}
275-
\index{back-quotes}
276-
277-
A string conversion is an expression list enclosed in reverse (a.k.a.
278-
backward) quotes:
279-
280-
\begin{productionlist}
281-
\production{string_conversion}
282-
{"`" \token{expression_list} "`"}
283-
\end{productionlist}
284-
285-
A string conversion evaluates the contained expression list and
286-
converts the resulting object into a string according to rules
287-
specific to its type.
288-
289-
If the object is a string, a number, \code{None}, or a tuple, list or
290-
dictionary containing only objects whose type is one of these, the
291-
resulting string is a valid Python expression which can be passed to
292-
the built-in function \function{eval()} to yield an expression with the
293-
same value (or an approximation, if floating point numbers are
294-
involved).
295-
296-
(In particular, converting a string adds quotes around it and converts
297-
``funny'' characters to escape sequences that are safe to print.)
298-
299-
Recursive objects (for example, lists or dictionaries that contain a
300-
reference to themselves, directly or indirectly) use \samp{...} to
301-
indicate a recursive reference, and the result cannot be passed to
302-
\function{eval()} to get an equal value (\exception{SyntaxError} will
303-
be raised instead).
304-
\obindex{recursive}
305-
306-
The built-in function \function{repr()} performs exactly the same
307-
conversion in its argument as enclosing it in parentheses and reverse
308-
quotes does. The built-in function \function{str()} performs a
309-
similar but more user-friendly conversion.
310-
\bifuncindex{repr}
311-
\bifuncindex{str}
312-
313-
314271
\section{Primaries\label{primaries}}
315272
\index{primary}
316273

Grammar/Grammar

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ power: atom trailer* ['**' factor]
102102
atom: ('(' [yield_expr|testlist_gexp] ')' |
103103
'[' [listmaker] ']' |
104104
'{' [dictmaker] '}' |
105-
'`' testlist1 '`' |
106105
NAME | NUMBER | STRING+)
107106
listmaker: test ( list_for | (',' test)* [','] )
108107
testlist_gexp: test ( gen_for | (',' test)* [','] )

Lib/tokenize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def maybe(*choices): return group(*choices) + '?'
8383
r"~")
8484

8585
Bracket = '[][(){}]'
86-
Special = group(r'\r?\n', r'[:;.,`@]')
86+
Special = group(r'\r?\n', r'[:;.,@]')
8787
Funny = group(Operator, Bracket, Special)
8888

8989
PlainToken = group(Number, Funny, String, Name)

Parser/tokenizer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ char *_PyParser_TokenNames[] = {
6767
"EQUAL",
6868
"DOT",
6969
"PERCENT",
70-
"BACKQUOTE",
7170
"LBRACE",
7271
"RBRACE",
7372
"EQEQUAL",
@@ -955,7 +954,6 @@ PyToken_OneChar(int c)
955954
case '=': return EQUAL;
956955
case '.': return DOT;
957956
case '%': return PERCENT;
958-
case '`': return BACKQUOTE;
959957
case '{': return LBRACE;
960958
case '}': return RBRACE;
961959
case '^': return CIRCUMFLEX;

Python/ast.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ static expr_ty
11901190
ast_for_atom(struct compiling *c, const node *n)
11911191
{
11921192
/* atom: '(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']'
1193-
| '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+
1193+
| '{' [dictmaker] '}' | NAME | NUMBER | STRING+
11941194
*/
11951195
node *ch = CHILD(n, 0);
11961196

@@ -1276,13 +1276,6 @@ ast_for_atom(struct compiling *c, const node *n)
12761276
}
12771277
return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);
12781278
}
1279-
case BACKQUOTE: { /* repr */
1280-
expr_ty expression = ast_for_testlist(c, CHILD(n, 1));
1281-
if (!expression)
1282-
return NULL;
1283-
1284-
return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena);
1285-
}
12861279
default:
12871280
PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch));
12881281
return NULL;

Python/compile.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,6 @@ opcode_stack_effect(int opcode, int oparg)
721721
case UNARY_POSITIVE:
722722
case UNARY_NEGATIVE:
723723
case UNARY_NOT:
724-
case UNARY_CONVERT:
725724
case UNARY_INVERT:
726725
return 0;
727726

@@ -2983,10 +2982,6 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
29832982
return compiler_compare(c, e);
29842983
case Call_kind:
29852984
return compiler_call(c, e);
2986-
case Repr_kind:
2987-
VISIT(c, expr, e->v.Repr.value);
2988-
ADDOP(c, UNARY_CONVERT);
2989-
break;
29902985
case Num_kind:
29912986
ADDOP_O(c, LOAD_CONST, e->v.Num.n, consts);
29922987
break;

0 commit comments

Comments
 (0)