[Boost-bugs] [Boost C++ Libraries] #11025: exec_file raises error if run in loop

Subject: [Boost-bugs] [Boost C++ Libraries] #11025: exec_file raises error if run in loop
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-02-14 10:10:42


#11025: exec_file raises error if run in loop
-------------------------------------+---------------------
 Reporter: edward.terhaar@… | Owner: rwgk
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: Python
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: file loop python script |
-------------------------------------+---------------------
 We tried to run a soak test of our code which uses boost::python, but
 found that after 509 runs the file could not be read. Found the cause to
 be boost::python not closing the FILE after an fopen. Line 91 in exec.cpp.

 Adding fclose(fs) after PyRun_File seemed to fix the problem.

 You can reproduce the problem with the following code:

 {{{
 int _tmain(int argc, _TCHAR* argv[])
 {
             int count = 0;
             Py_Initialize();
             while (true)
             {
                         auto strScriptFile =
 "D:\\Scrap\\ConsoleApplication2\\SampleCustomMacroOne.py";

                         object main_module = import("__main__");
                         dict globalDict =
 extract<dict>(main_module.attr("__dict__"));
                         exec_file(strScriptFile, globalDict);

                         std::cout << count << endl;
                         count++;
             }

             return 0;
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11025>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC