2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 04:42:28 +00:00

[#8058] Close file handle before exec_file() routine returns.

This commit is contained in:
Mikhail Matrosov
2015-03-11 00:55:42 +03:00
parent a911c17fd6
commit fe24ab9dd5

View File

@@ -96,10 +96,12 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local)
FILE *fs = PyFile_AsFile(file.get());
#endif
PyObject* result = PyRun_File(fs,
int closeit = 1; // Close file before PyRun returns
PyObject* result = PyRun_FileEx(fs,
f,
Py_file_input,
global.ptr(), local.ptr());
global.ptr(), local.ptr(),
closeit);
if (!result) throw_error_already_set();
return object(detail::new_reference(result));
}