[Python-Dev] Should I/O object wrappers close their underlying buffer when deleted?
alexandre at peadrop.com
Sun Apr 5 08:28:52 CEST 2009
I would like to call to your attention the following behavior of TextIOWrapper:
textio = io.TextIOWrapper(buf)
buf = io.BytesIO()
print(buf.closed) # This prints True currently
The problem here is TextIOWrapper closes its buffer when deleted.
BufferedRWPair behalves similarly. The solution is simply to override
the __del__ method of TextIOWrapper inherited from IOBase.
More information about the Python-Dev