mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Explicitly close some files (from issue #10093)
This commit is contained in:
parent
d9f57630fe
commit
b86680e299
6 changed files with 31 additions and 14 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue