This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients arigo, neologix, pitrou, serhiy.storchaka, vstinner
Date 2014-11-19.15:36:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1416411379.96.0.493313177459.issue17852@psf.upfronthosting.co.za>
In-reply-to
Content
Is anyone interested to work on the "maintain a list of open file objects" idea?

I consider that Python 3 does its best to flush data at exit, but it's not a good practice to rely on the destructors to flush data. I mean, there is no warranty that files will be written in the correct order and that files will stay consistent. It's much safer to explicitly call the clode() method.

By the way, Python 3 now emits ResourceWarning warnings when files are destroyed without being explicitly closed. I enhanced the code handling warnings during Python shutdown to show these warnings in more use cases, but it is still not perfect. I opened the issue #21788 as a reminder that the code can still be enhanced.

For the "maintain a list of objects" idea, I expect race conditions with threads, signals and processes (fork). We already have known issues with locks + fork. I expect even more issues if we maintain a list of open files.

I propose to close the issue as "wontfix". Python 3 does its best, but please call explicitly the close() method!

Maybe the undefined behaviour should be documented (with a warning?) in the buffered writer of the io module, and maybe also in the open() function?
History
Date User Action Args
2014-11-19 15:36:20vstinnersetrecipients: + vstinner, arigo, pitrou, neologix, serhiy.storchaka
2014-11-19 15:36:19vstinnersetmessageid: <1416411379.96.0.493313177459.issue17852@psf.upfronthosting.co.za>
2014-11-19 15:36:19vstinnerlinkissue17852 messages
2014-11-19 15:36:19vstinnercreate