r""" >>> import io >>> read_unicodestringnl(io.BytesIO(b"abc\\uabcd\njunk")) == 'abc\uabcd' True
(f)
| 601 | """) |
| 602 | |
| 603 | def read_unicodestringnl(f): |
| 604 | r""" |
| 605 | >>> import io |
| 606 | >>> read_unicodestringnl(io.BytesIO(b"abc\\uabcd\njunk")) == 'abc\uabcd' |
| 607 | True |
| 608 | """ |
| 609 | |
| 610 | data = f.readline() |
| 611 | if not data.endswith(b'\n'): |
| 612 | raise ValueError("no newline found when trying to read " |
| 613 | "unicodestringnl") |
| 614 | data = data[:-1] # lose the newline |
| 615 | return str(data, 'raw-unicode-escape') |
| 616 | |
| 617 | unicodestringnl = ArgumentDescriptor( |
| 618 | name='unicodestringnl', |