From 5595c5a2dcc4d7be7231d9d2d7e7e46b95242ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Londeix?= Date: Fri, 8 Jan 2016 11:54:29 +0100 Subject: [PATCH] Close the file handle used in exec_file() For python >= 3, a plain `FILE*` is used, whereas for python2, an object handle takes care of the file object lifetime. This commit manually closes the file handle after the `PyRun_File()` call. --- src/exec.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/exec.cpp b/src/exec.cpp index fa2860e40..7b0421054 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -101,6 +101,9 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local) f, Py_file_input, global.ptr(), local.ptr()); +#if PY_VERSION_HEX >= 0x03000000 + fclose(fs); +#endif if (!result) throw_error_already_set(); return object(detail::new_reference(result)); }