StringIO that takes bytes or str.
| 187 | |
| 188 | |
| 189 | class WhateverIO(StringIO): |
| 190 | """StringIO that takes bytes or str.""" |
| 191 | |
| 192 | def __init__( |
| 193 | self, v: bytes | str | None = None, *a: Any, **kw: Any) -> None: |
| 194 | _SIO_init(self, v.decode() if isinstance(v, bytes) else v, *a, **kw) |
| 195 | |
| 196 | def write(self, data: bytes | str) -> int: |
| 197 | return _SIO_write(self, data.decode() |
| 198 | if isinstance(data, bytes) else data) |
no outgoing calls