-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
boost::python::file_exec not fully closing file with Python 3.4.3 #52
Comments
It might be that std::fstream uses _fsopen() internally. In any case I would expect that exec_file() releases the file handle. |
The extra b tells the file to be opened in binary mode (https://msdn.microsoft.com/en-us/library/z5hh6ee9.aspx).
So hopefully that detail isn't critical to the example. I've got my main project working by using Python's C API to execute the file (https://docs.python.org/3.5/c-api/veryhigh.html?highlight=pyrun_#c.PyRun_FileEx). The API includes parameters that specifically refer to the file being closed after execution, which is partly why I'm suspicious of boost::python::exec_file in the example above. |
Yes, you're right. I think the bug is indeed in |
Thank you, I will do. I'm not sure how long it will take, so it might be Monday before I can get back you you. |
There was a related issue reported in the past that has been addressed in Boost.Python 1.59 or earlier. Could you try a newer version (like the current Boost 1.60) to make sure you are not seeing a bug that's already ben fixed ? |
Unfortunately I can't currently try a newer version of Boost, sorry. I agree that it would be preferable to test the example with 1.60 if possible though. Copying the change from #53 into Boost 1.57 has fixed the problem in the example, so provisionally it looks good. |
Sounds like this is fixed now. |
Using Python 3.4.3 and Boost 1.57.0 on 64-bit Windows 7 with Visual Studio 2013.
After boost::python::exec_file is called on a file, that file can't be modified by the program using fopen_s, I think because it is still open.
In the following example, when ModifyFile is called before executing the file, it succeeds. After the file has been executed, fopen_s returns 13 (Permission denied) and ModifyFile fails.
I have tried a similar example using std::fstream to modify the file, and this doesn't seem to have the same problems.
The text was updated successfully, but these errors were encountered: