]> granicus.if.org Git - python/commitdiff
SF bug #488687 reported by Neal Norwitz
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 4 Dec 2001 02:41:46 +0000 (02:41 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 4 Dec 2001 02:41:46 +0000 (02:41 +0000)
The error for assignment to __debug__ used ste->ste_opt_lineno instead
of n->n_lineno.  The latter was at best incorrect; often the slot was
uninitialized.  Two fixes here: Use the correct lineno for the error.
Initialize ste_opt_lineno in PySymtable_New(); while there are no
current cases where it is referenced unless it has already been
assigned to, there is no harm in initializing it.

Python/compile.c
Python/symtable.c

index 4b2cd07065cc91f77666f7312dc943edcae1a206..d76769c446ee5e6d9bc5f21a2e48f2749eaa3f3a 100644 (file)
@@ -5464,7 +5464,7 @@ symtable_assign(struct symtable *st, node *n, int def_flag)
                                PyErr_SetString(PyExc_SyntaxError, 
                                                ASSIGN_DEBUG);
                                PyErr_SyntaxLocation(st->st_filename,
-                                            st->st_cur->ste_opt_lineno);
+                                                    n->n_lineno);
                                st->st_errors++;
                        }
                        symtable_add_def(st, STR(tmp), DEF_LOCAL | def_flag);
index 080bfd5aa335bdd170c530392d454b3820000cee..74d2b82c3985eb332f6abae39a356adfafa061e0 100644 (file)
@@ -45,6 +45,7 @@ PySymtableEntry_New(struct symtable *st, char *name, int type, int lineno)
        ste->ste_children = v;
 
        ste->ste_optimized = 0;
+       ste->ste_opt_lineno = 0;
        ste->ste_lineno = lineno;
        switch (type) {
        case funcdef: