2017-06-05 16:54:21 -04:00
|
|
|
# Make sure that write operations on io.BytesIO don't
|
|
|
|
# change original object it was constructed from.
|
2022-08-18 02:57:45 -04:00
|
|
|
import io
|
2017-06-05 16:54:21 -04:00
|
|
|
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())
|