Explicitly close some files (from issue #10093)

This commit is contained in:
Antoine Pitrou 2010-10-14 21:15:17 +00:00
parent d9f57630fe
commit b86680e299
6 changed files with 31 additions and 14 deletions

View file

@ -208,6 +208,7 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
PyObject *binary;
PyObject *fob = NULL;
PyObject *lineobj = NULL;
PyObject *res;
char buf[MAXPATHLEN+1];
Py_UNICODE *u, *p;
Py_ssize_t len;
@ -253,6 +254,11 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
break;
}
}
res = PyObject_CallMethod(fob, "close", "");
if (res)
Py_DECREF(res);
else
PyErr_Clear();
Py_DECREF(fob);
if (!lineobj || !PyUnicode_Check(lineobj)) {
Py_XDECREF(lineobj);