Python package bytesbufio
bytesbufio provides BytesBufferIO - an io.BytesIO implementation whose value can be accessed after it has been closed
pip install bytesbufio
import io from bytesbufio import BytesBufferIO bytesbuf = BytesBufferIO() with io.TextIOWrapper(bytesbuf, encoding='utf-8') as textout: textout.write("Hello world.") text = bytesbuf.getvalue().decode('utf-8') # BytesIO would have raised an ValueError here print(text)
- Python Issue 22003 - BytesIO and shared bufferes
- Python Issue 23099 - value not available after close
Copyright (c) 2020 by Cornelius Buschka.