summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-02-28 22:08:12 (GMT)
committerGuido van Rossum <guido@python.org>2001-02-28 22:08:12 (GMT)
commitee34ac124a92d98590d2949feaa91c99e228143c (patch)
treea4e1bf42403ebb7e03095347c0bdaa29da054a80
parent58177b9975171060ed29248fc4a984a036f579ff (diff)
downloadcpython-ee34ac124a92d98590d2949feaa91c99e228143c.zip
cpython-ee34ac124a92d98590d2949feaa91c99e228143c.tar.gz
cpython-ee34ac124a92d98590d2949feaa91c99e228143c.tar.bz2
Let's have some sanity. Introduce a helper to issue a symbol table
warning.
-rw-r--r--Python/compile.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 6b5fa11..2646dbe 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3983,6 +3983,22 @@ get_ref_type(struct compiling *c, char *name)
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 @@ symtable_global(struct symtable *st, node *n)
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);