STINNER Victor added the comment:

Attached patch modifies _pyio to mimick better the reference io module:

* Add IOBase._finalizing
* IOBase.__del__() sets _finalizing to True
* Add FileIO._dealloc_warn()
* Remove FileIO.__del__()
* FileIO.close(), _BufferedIOMixin.close() and TextIOWrapper.close() now calls 
_dealloc_warn() if _finalizing is true
* Override closed() method in FileIO: needed because FileIO.close() now calls 
super().close() before logging the ResourceWarning, and the file is expected to 
see open in the warning
* FileIO.close() now calls super().close() *before* closing the file descriptor

I added hasattr(.., '_dealloc_warn') sanity checks because _dealloc_warn() are 
added to concrete classes, not to base classes.

----------
Added file: http://bugs.python.org/file42271/pyio_res_warn.patch

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

Reply via email to