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 Arfrever, akira, martin.panter, piotr.dobrogost, pitrou, serhiy.storchaka, vstinner
Date 2016-03-24.14:15:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458828958.46.0.629459261211.issue19829@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-03-24 14:15:58vstinnersetrecipients: + vstinner, pitrou, Arfrever, akira, martin.panter, piotr.dobrogost, serhiy.storchaka
2016-03-24 14:15:58vstinnersetmessageid: <1458828958.46.0.629459261211.issue19829@psf.upfronthosting.co.za>
2016-03-24 14:15:58vstinnerlinkissue19829 messages
2016-03-24 14:15:58vstinnercreate