StringIO that takes bytes or str.
| 197 | |
| 198 | |
| 199 | class WhateverIO(StringIO): |
| 200 | """StringIO that takes bytes or str.""" |
| 201 | |
| 202 | def __init__( |
| 203 | self, v: bytes | str | None = None, *a: Any, **kw: Any) -> None: |
| 204 | _SIO_init(self, v.decode() if isinstance(v, bytes) else v, *a, **kw) |
| 205 | |
| 206 | def write(self, data: bytes | str) -> int: |
| 207 | return _SIO_write(self, data.decode() |
| 208 | if isinstance(data, bytes) else data) |
no outgoing calls