diff options
author | Barry Warsaw <barry@python.org> | 1997-09-18 03:44:38 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1997-09-18 03:44:38 (GMT) |
commit | b01a7fa5f8208fb5c767964e63b44f0a02814f62 (patch) | |
tree | a9a5dd5b8bcbbf9574d207a35738947c73464f16 /Python/bltinmodule.c | |
parent | 412cdc2284693c07a3ab7c812284b0a95ffa0724 (diff) | |
download | cpython-b01a7fa5f8208fb5c767964e63b44f0a02814f62.zip cpython-b01a7fa5f8208fb5c767964e63b44f0a02814f62.tar.gz cpython-b01a7fa5f8208fb5c767964e63b44f0a02814f62.tar.bz2 |
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! :-)
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 65cfa6f..15cca17 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -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); |