[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

STINNER Victor report at bugs.python.org
Thu Mar 24 11:36:40 EDT 2016


STINNER Victor added the comment:

> I don't like _dealloc_warn() at all. It looks as a dirty hack and doesn't work with custom file-like objects.

I tried to support emitting a ResourceWarning when the close() method is overriden in a subclass, but then I saw that io doesn't support this use case neither:
---
import io
import os

class MyFile(io.FileIO):
    def close(self):
        os.close(self.fileno())

f = MyFile('/etc/issue')
f = None
---
=> no warning

Ok, now I have to read again Martin's patches since I didn't understand them at the first read :-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19829>
_______________________________________


More information about the Python-bugs-list mailing list