r""" >>> import io >>> read_string1(io.BytesIO(b"\x00")) '' >>> read_string1(io.BytesIO(b"\x03abcdef")) 'abc'
(f)
| 407 | |
| 408 | |
| 409 | def read_string1(f): |
| 410 | r""" |
| 411 | >>> import io |
| 412 | >>> read_string1(io.BytesIO(b"\x00")) |
| 413 | '' |
| 414 | >>> read_string1(io.BytesIO(b"\x03abcdef")) |
| 415 | 'abc' |
| 416 | """ |
| 417 | |
| 418 | n = read_uint1(f) |
| 419 | assert n >= 0 |
| 420 | data = f.read(n) |
| 421 | if len(data) == n: |
| 422 | return data.decode("latin-1") |
| 423 | raise ValueError("expected %d bytes in a string1, but only %d remain" % |
| 424 | (n, len(data))) |
| 425 | |
| 426 | string1 = ArgumentDescriptor( |
| 427 | name="string1", |
nothing calls this directly
no test coverage detected
searching dependent graphs…