Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 16855:ec9083ac26df legacy-trunk
Let's have some sanity. Introduce a helper to issue a symbol table
warning.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 28 Feb 2001 22:08:12 +0000 |
| parents | 05785bdf289c |
| children | 77a5470299db |
line wrap: on
line diff
--- a/Python/compile.c Wed Feb 28 22:05:41 2001 +0000 +++ b/Python/compile.c Wed Feb 28 22:08:12 2001 +0000 @@ -3983,6 +3983,22 @@ return -1; /* can't get here */ } +/* Helper function to issue symbol table warnings */ + +static void +symtable_warn(struct symtable *st, char *msg) +{ + if (PyErr_WarnExplicit(PyExc_SyntaxWarning, msg, st->st_filename, + st->st_cur->ste_lineno, NULL, NULL) < 0) { + if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) { + PyErr_SetString(PyExc_SyntaxError, msg); + PyErr_SyntaxLocation(st->st_filename, + st->st_cur->ste_lineno); + } + st->st_errors++; + } +} + /* Helper function for setting lineno and filename */ static int @@ -4837,22 +4853,7 @@ name); else sprintf(buf, GLOBAL_AFTER_USE, name); - if (PyErr_WarnExplicit(PyExc_SyntaxWarning, - buf, st->st_filename, - st->st_cur->ste_lineno, - NULL, NULL) < 0) - { - if (PyErr_ExceptionMatches( - PyExc_SyntaxWarning)) - { - PyErr_SetString( - PyExc_SyntaxError, buf); - PyErr_SyntaxLocation( - st->st_filename, - st->st_cur->ste_lineno); - } - st->st_errors++; - } + symtable_warn(st, buf); } } symtable_add_def(st, name, DEF_GLOBAL);
