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! :-)
This commit is contained in:
Barry Warsaw 1997-09-18 03:44:38 +00:00
parent 412cdc2284
commit b01a7fa5f8
1 changed files with 3 additions and 3 deletions

View File

@ -1896,11 +1896,11 @@ initerrors(dict)
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);