diff Python/symtable.c @ 35893:825655bfdf20 legacy-trunk

Last batch of ref leaks in new AST code. Also converted a bunch of assert(0) to SystemError's. There are still printfs, etc that need to be cleaned up.
author Neal Norwitz <nnorwitz@gmail.com>
date Sat, 19 Nov 2005 23:58:29 +0000
parents 0d1e2e73c3ec
children 79374eb6db51
line wrap: on
line diff
--- a/Python/symtable.c	Sat Nov 19 18:43:38 2005 +0000
+++ b/Python/symtable.c	Sat Nov 19 23:58:29 2005 +0000
@@ -731,7 +731,6 @@
 	if (st->st_cur) {
 		prev = st->st_cur;
 		if (PyList_Append(st->st_stack, (PyObject *)st->st_cur) < 0) {
-			Py_DECREF(st->st_cur);
 			return 0;
 		}
 		Py_DECREF(st->st_cur);
@@ -814,6 +813,7 @@
 		}
 		Py_DECREF(o);
 	}
+	Py_DECREF(mangled);
 	return 1;
 
 error:
@@ -1087,9 +1087,10 @@
 
 		PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]",
 			      ++st->st_cur->ste_tmpname);
-		tmp = PyString_FromString(tmpname);
+		tmp = PyString_InternFromString(tmpname);
 		if (!symtable_add_def(st, tmp, DEF_LOCAL))
 			return 0;
+		Py_DECREF(tmp);
 		VISIT(st, expr, e->v.ListComp.elt);
 		VISIT_SEQ(st, comprehension, e->v.ListComp.generators);
 		break;
@@ -1186,8 +1187,10 @@
 			}
 		}
 		else {
-			/* syntax error */
-			fprintf(stderr, "unexpected expr in parameter list\n");
+		        PyErr_SetString(PyExc_SyntaxError,
+					"invalid expression in parameter list");
+		        PyErr_SyntaxLocation(st->st_filename,
+				             st->st_cur->ste_lineno);
 			return 0;
 		}
 	}
@@ -1279,6 +1282,7 @@
                     return 0;
             }
 	    st->st_cur->ste_unoptimized |= OPT_IMPORT_STAR;
+	    Py_DECREF(store_name);
 	    return 1;
 	}
 }