summaryrefslogtreecommitdiffstatshomepage
path: root/tests/io/bytesio_cow.py
blob: 92654a0003fb6a8b4e18f95977bc434ed7fabf43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Make sure that write operations on io.BytesIO don't
# change original object it was constructed from.
try:
    import uio as io
except ImportError:
    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())