The documentation suggests that BytesIO
is the new StringIO
, because it supports current-relative seeks.
However, this is incorrect.
BytesIO
cannot be used uniformly with TextIOWrappers
as they are returned by open()
calls. The former returns bytes the later returns text objects when reading.
TextIOWrapper(BytesIO(...))
also, does not do work as desired, because again, it does not support relative seeks.
So what is the best construct to replace the python2 StringIO
in python3?