Why is TextIOWrapper closing the given BytesIO stream?
问题 If I run following code in python 3 from io import BytesIO import csv from io import TextIOWrapper def fill_into_stringio(input_io): writer = csv.DictWriter(TextIOWrapper(input_io, encoding='utf-8'),fieldnames=['ids']) for i in range(100): writer.writerow({'ids': str(i)}) with BytesIO() as input_i: fill_into_stringio(input_i) input_i.seek(0) I get an error: ValueError: I/O operation on closed file. While if I don't use the TextIOWrapper the io stream stays open. As an example if I modify my