Neil Schemenauer <nas-pyt...@arctrix.com> added the comment:

Attached is a script that triggers the non-flushing behaviour for me.  I don't 
think it is reliable since it depends on the order that FileIO AND 
BufferedWriter are finalized when the gc finds them in a reference cycle.

BTW, it is arguable that the root cause of this bug is that we no longer to 
topological ordering when calling finalizers.  Originally, the cycle GC would 
refuse to call __del__ methods because once they are part of a cycle, there is 
no defined topological ordering.  So, we linked that garage to gc.garbage 
rather than calling __del__ and have potentially undefined results.  Now the GC 
has been changed to call __del__ anyhow.   I haven't studied how this has been 
changed but this non-flushing bug is a result.  Having the buffer added to 
gc.garbage would also result in the data not being flushed but arguably it 
would be more understandable what's going on.  I'm not arguing that we should 
go back to that, just that current behaviour can be subtle and confusing.

----------
Added file: https://bugs.python.org/file47332/buffer_not_flushed.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue17852>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to