]> granicus.if.org Git - python/commitdiff
Fixed problems in the last commit. Filenames and line numbers weren't reported correctly.
authorChristian Heimes <christian@cheimes.de>
Fri, 23 Nov 2007 12:12:02 +0000 (12:12 +0000)
committerChristian Heimes <christian@cheimes.de>
Fri, 23 Nov 2007 12:12:02 +0000 (12:12 +0000)
Backquotes still don't report the correct file. The AST nodes only contain the line number but not the file name.

Parser/tokenizer.c
Python/ast.c

index 432f94f6f39f38961e304f7af6b7d4995cd5179a..4ff2b98589addf63716e9aac2f33efcb149a17ea 100644 (file)
@@ -983,15 +983,7 @@ PyToken_TwoChars(int c1, int c2)
                break;
        case '<':
                switch (c2) {
-               case '>':
-                       {
-#ifndef PGEN
-                               if (Py_Py3kWarningFlag)
-                                       PyErr_WarnEx(PyExc_DeprecationWarning,
-                                               "<> not supported in 3.x", 1);
-#endif
-                               return NOTEQUAL;
-                       }
+               case '>':       return NOTEQUAL;
                case '=':       return LESSEQUAL;
                case '<':       return LEFTSHIFT;
                }
@@ -1485,6 +1477,16 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
        {
                int c2 = tok_nextc(tok);
                int token = PyToken_TwoChars(c, c2);
+#ifndef PGEN
+               if (token == NOTEQUAL && c == '<') {
+                       if (PyErr_WarnExplicit(PyExc_DeprecationWarning,
+                                              "<> not supported in 3.x",
+                                              tok->filename, tok->lineno,
+                                              NULL, NULL)) {
+                               return ERRORTOKEN;
+                       }
+               }
+#endif
                if (token != OP) {
                        int c3 = tok_nextc(tok);
                        int token3 = PyToken_ThreeChars(c, c2, c3);
index 5555cf7ddf8ae3d2a3f34b8fae51938ff4e38bbb..9354b59cb0d51f6125d83609727ec30f5dbaeac3 100644 (file)
@@ -1336,10 +1336,14 @@ ast_for_atom(struct compiling *c, const node *n)
         return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);
     }
     case BACKQUOTE: { /* repr */
-        if (Py_Py3kWarningFlag &&
-            PyErr_Warn(PyExc_DeprecationWarning,
-                "backquote not supported in 3.x") < 0)
-            return NULL;
+        if (Py_Py3kWarningFlag) {
+               if (PyErr_WarnExplicit(PyExc_DeprecationWarning,
+                                      "backquote not supported in 3.x",
+                                      "<unknown>", LINENO(n),
+                                      NULL, NULL)) {
+                       ; //return NULL;
+               }
+       }
         expr_ty expression = ast_for_testlist(c, CHILD(n, 1));
         if (!expression)
             return NULL;