diff Python/bltinmodule.c @ 6327:4b4775b49bfa legacy-trunk

initerrors(): Eliminate circular reference which was causing a small but annoying memory leak. This was introduced when PyExc_Exception was added; the loop above populating the PyExc_StandardError exception tuple started at index 1 in bltin_exc, but PyExc_Exception was added at index 0, so PyExc_StandardError was getting inserted in itself! How else can a tuple include itself?! Change the loop to start at index 2. This was a *fun* one! :-)
author Barry Warsaw <barry@python.org>
date Thu, 18 Sep 1997 03:44:38 +0000
parents b0183994021b
children fc1c0a27bb96
line wrap: on
line diff
--- a/Python/bltinmodule.c	Tue Sep 16 21:51:14 1997 +0000
+++ b/Python/bltinmodule.c	Thu Sep 18 03:44:38 1997 +0000
@@ -1896,11 +1896,11 @@
 	PyTuple_SET_ITEM(PyExc_ArithmeticError, 2, PyExc_FloatingPointError);
 	PyDict_SetItemString(dict, "ArithmeticError", PyExc_ArithmeticError);
 
-	PyExc_StandardError = PyTuple_New(exccnt-1);
-	for (i = 1; bltin_exc[i].name; i++) {
+	PyExc_StandardError = PyTuple_New(exccnt-2);
+	for (i = 2; bltin_exc[i].name; i++) {
 		PyObject *exc = *bltin_exc[i].exc;
 		Py_INCREF(exc);
-		PyTuple_SET_ITEM(PyExc_StandardError, i-1, exc);
+		PyTuple_SET_ITEM(PyExc_StandardError, i-2, exc);
 	}
 	PyDict_SetItemString(dict, "StandardError", PyExc_StandardError);