io_bytesio_cow.py 329 B

1234567891011121314151617181920
  1. # Make sure that write operations on io.BytesIO don't
  2. # change original object it was constructed from.
  3. try:
  4. import uio as io
  5. except ImportError:
  6. import io
  7. b = b"foobar"
  8. a = io.BytesIO(b)
  9. a.write(b"1")
  10. print(b)
  11. print(a.getvalue())
  12. b = bytearray(b"foobar")
  13. a = io.BytesIO(b)
  14. a.write(b"1")
  15. print(b)
  16. print(a.getvalue())