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 serhiy.storchaka
Recipients arigo, neologix, nikratio, pitrou, serhiy.storchaka, tim.peters, vstinner
Date 2014-12-04.13:39:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624549.WHV8HQtcLC@raxxla>
In-reply-to <1417698629.16.0.54551573602.issue17852@psf.upfronthosting.co.za>
Content
How it looks to me. Should be global collection of weak references (WeakSet?). 
Every instance of TextIOWrapper, BufferedWriter and BufferedRandom add itself to 
this collection on create and remove on close. A function registered with 
atexit calls flush() for all methods in the collection.

This solution doesn't require changes to finalization machinery, only to the io 
module.

I'm not particularly interested to implement that because I'm not convinced 
that Python should provide such guaranties. But the implementation shouldn't 
be too complex.

More general solution could be to introduce special method (__predel__) which 
should be called before breaking reference loops (or just before __del__ if 
there is no loop). In case of output streams it will call flush() (but not 
close()!).
History
Date User Action Args
2014-12-04 13:39:37serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, arigo, pitrou, vstinner, nikratio, neologix
2014-12-04 13:39:37serhiy.storchakalinkissue17852 messages
2014-12-04 13:39:36serhiy.storchakacreate