Skip to content
Snippets Groups Projects
Select Git revision
  • 2c915e1ae61785ab6e33189581fb353ebd40d0ca
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

compile.c

Blame
  • buffered_writer.py 560 B
    import uio as io
    
    try:
        io.BytesIO
        io.BufferedWriter
    except AttributeError:
        import sys
        print('SKIP')
        sys.exit()
    
    bts = io.BytesIO()
    buf = io.BufferedWriter(bts, 8)
    
    buf.write(b"foobar")
    print(bts.getvalue())
    buf.write(b"foobar")
    # CPython has different flushing policy, so value below is different
    print(bts.getvalue())
    buf.flush()
    print(bts.getvalue())
    buf.flush()
    print(bts.getvalue())
    
    # special case when alloc is a factor of total buffer length
    bts = io.BytesIO()
    buf = io.BufferedWriter(bts, 1)
    buf.write(b"foo")
    print(bts.getvalue())