Skip to content

Commit 205a7eb

Browse files
author
christian.heimes
committed
Fixed problems in the last commit. Filenames and line numbers weren't reported correctly.
Backquotes still don't report the correct file. The AST nodes only contain the line number but not the file name. git-svn-id: http://svn.python.org/projects/python/trunk@59133 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent e00db1f commit 205a7eb

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

Parser/tokenizer.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -983,15 +983,7 @@ PyToken_TwoChars(int c1, int c2)
983983
break;
984984
case '<':
985985
switch (c2) {
986-
case '>':
987-
{
988-
#ifndef PGEN
989-
if (Py_Py3kWarningFlag)
990-
PyErr_WarnEx(PyExc_DeprecationWarning,
991-
"<> not supported in 3.x", 1);
992-
#endif
993-
return NOTEQUAL;
994-
}
986+
case '>': return NOTEQUAL;
995987
case '=': return LESSEQUAL;
996988
case '<': return LEFTSHIFT;
997989
}
@@ -1485,6 +1477,16 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
14851477
{
14861478
int c2 = tok_nextc(tok);
14871479
int token = PyToken_TwoChars(c, c2);
1480+
#ifndef PGEN
1481+
if (token == NOTEQUAL && c == '<') {
1482+
if (PyErr_WarnExplicit(PyExc_DeprecationWarning,
1483+
"<> not supported in 3.x",
1484+
tok->filename, tok->lineno,
1485+
NULL, NULL)) {
1486+
return ERRORTOKEN;
1487+
}
1488+
}
1489+
#endif
14881490
if (token != OP) {
14891491
int c3 = tok_nextc(tok);
14901492
int token3 = PyToken_ThreeChars(c, c2, c3);

Python/ast.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,10 +1336,14 @@ ast_for_atom(struct compiling *c, const node *n)
13361336
return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);
13371337
}
13381338
case BACKQUOTE: { /* repr */
1339-
if (Py_Py3kWarningFlag &&
1340-
PyErr_Warn(PyExc_DeprecationWarning,
1341-
"backquote not supported in 3.x") < 0)
1342-
return NULL;
1339+
if (Py_Py3kWarningFlag) {
1340+
if (PyErr_WarnExplicit(PyExc_DeprecationWarning,
1341+
"backquote not supported in 3.x",
1342+
"<unknown>", LINENO(n),
1343+
NULL, NULL)) {
1344+
; //return NULL;
1345+
}
1346+
}
13431347
expr_ty expression = ast_for_testlist(c, CHILD(n, 1));
13441348
if (!expression)
13451349
return NULL;

0 commit comments

Comments
 (0)