[issue21363] io.TextIOWrapper always closes wrapped files
Mitar
report at bugs.python.org
Sat Oct 20 12:13:57 EDT 2018
Mitar <mmitar at gmail.com> added the comment:
I have a similar problem that text wrapper is closing the handle, and if I want to make a workaround, it also fails:
buffer = io.Bytes()
with io.TextIOWrapper(buffer, encoding='utf8') as text_buffer:
write_content_to(text_buffer)
text_buffer.flush()
text_buffer.detach()
Now this fails when context manager is trying to close the text_buffer with an error that it is already detached. If I do not detach it, then it closes buffer as well.
----------
nosy: +mitar
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue21363>
_______________________________________
More information about the Python-bugs-list
mailing list