Closed robert-hh closed 3 years ago
Hello! Good catch, it was hard to decode because without removing the _m_del_obj(pyb_file_objt, self) call the exception is dropped by _mp_load_methodmaybe(). I checked your example the issue happens and your fix solves it.
However with the following example, without your fix, the problem does not come alive: `
f = open("myfile.txt", "w") f.write("ssss") 4 f.close() f.close() Traceback (most recent call last): File "
", line 1, in AttributeError: 'function' object has no attribute 'close' `
I think here the exception is correct, because the file object ("f") is deleted by _m_del_obj(pyb_file_objt, self).
It would be interesting to see why the crash happens with your example and why it does not with this other example.
I'm a little bit reluctant to delete python objects deep inside drivers, unless you know that they are not used any more. When I wrote that, I had a clear opinion why it was wrong here, but now I do not know it any more. Anyhow, it does not to keep it and let the garbage collector do the job later.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Thanks, this fix looks good !
Fixed in 1.20.3.b3
An attempt to close a file twice resulted in a crash, because buffers should have been freed again. This change checks first, if a file is already closed.