circuitpython/tests/basics/io_bytesio_cow.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
279 B
Python
Raw Normal View History

# Make sure that write operations on io.BytesIO don't
# change original object it was constructed from.
2023-08-22 11:15:46 -04:00
import io
b = b"foobar"
a = io.BytesIO(b)
a.write(b"1")
print(b)
print(a.getvalue())
b = bytearray(b"foobar")
a = io.BytesIO(b)
a.write(b"1")
print(b)
print(a.getvalue())