Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I wrap Python 3's io.BytesIO() with surrogateescape decoding?

I've found Python3's open("filename", "r", encoding="ascii", errors="surrogateescape") to be useful. How do I wrap an io.BytesIO() (or any not-a-real-file source of bytes) to create a text-mode file-like object with the same decoding behavior?

like image 233
joeforker Avatar asked Feb 23 '26 02:02

joeforker


1 Answers

That's what TextIOWrapper does.

like image 108
Lennart Regebro Avatar answered Feb 25 '26 14:02

Lennart Regebro