summaryrefslogtreecommitdiff
path: root/tests/basics/io_bytesio_cow.py
blob: 543c12ad42ab2d52a4c721c714d1d416f92e19b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Make sure that write operations on io.BytesIO don't
# change original object it was constructed from.

try:
    import io
except ImportError:
    print("SKIP")
    raise SystemExit

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())