Helper IO class. Writes encode strings to bytes if needed, reads return bytes. This makes it easier to emulate files opened in binary mode without needing to explicitly convert strings to bytes in setting up the test data.
| 40 | |
| 41 | |
| 42 | class TextIO(BytesIO): |
| 43 | """Helper IO class. |
| 44 | |
| 45 | Writes encode strings to bytes if needed, reads return bytes. |
| 46 | This makes it easier to emulate files opened in binary mode |
| 47 | without needing to explicitly convert strings to bytes in |
| 48 | setting up the test data. |
| 49 | |
| 50 | """ |
| 51 | def __init__(self, s=""): |
| 52 | BytesIO.__init__(self, asbytes(s)) |
| 53 | |
| 54 | def write(self, s): |
| 55 | BytesIO.write(self, asbytes(s)) |
| 56 | |
| 57 | def writelines(self, lines): |
| 58 | BytesIO.writelines(self, [asbytes(s) for s in lines]) |
| 59 | |
| 60 | |
| 61 | IS_64BIT = sys.maxsize > 2**32 |
no outgoing calls
searching dependent graphs…