Bug in io.TextIOWrapper?
Inada Naoki
songofacandy at gmail.com
Mon Jun 19 14:19:48 EDT 2023
You can use file instead of BytesIO
2023年6月20日(火) 3:05 Peter J. Holzer via Python-list <python-list at python.org>:
> On 2023-06-20 02:15:00 +0900, Inada Naoki via Python-list wrote:
> > stream.flush() doesn't mean final output.
> > Try stream.close()
>
> After close() the value isn't available any more:
>
> Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import io
> >>> buffer = io.BytesIO()
> >>> stream = io.TextIOWrapper(buffer, encoding='idna')
> >>> stream.write('abc.example.com')
> 15
> >>> stream.close()
> >>> buffer.getvalue()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ValueError: I/O operation on closed file.
>
> hp
>
> --
> _ | Peter J. Holzer | Story must make more sense than reality.
> |_|_) | |
> | | | hjp at hjp.at | -- Charles Stross, "Creative writing
> __/ | http://www.hjp.at/ | challenge!"
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list