bytebufio

io.BytesIO that preserves bytes after close


Keywords
python3
License
Apache-2.0
Install
pip install bytebufio==1.0.0

Documentation

Python package bytesbufio

Sources Written in Python PyPI Build Status codecov License

bytesbufio provides BytesBufferIO - an io.BytesIO implementation whose value can be accessed after it has been closed

Installation

pip install bytesbufio

Usage

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)

Related

License

Copyright (c) 2020 by Cornelius Buschka.

Apache License, Version 2.0