(
input: str | bytes | t.IO[t.Any] | None, charset: str
)
| 209 | |
| 210 | |
| 211 | def make_input_stream( |
| 212 | input: str | bytes | t.IO[t.Any] | None, charset: str |
| 213 | ) -> t.BinaryIO: |
| 214 | # Is already an input stream. |
| 215 | if hasattr(input, "read"): |
| 216 | rv = _find_binary_reader(t.cast("t.IO[t.Any]", input)) |
| 217 | |
| 218 | if rv is not None: |
| 219 | return rv |
| 220 | |
| 221 | raise TypeError("Could not find binary reader for input stream.") |
| 222 | |
| 223 | if input is None: |
| 224 | input = b"" |
| 225 | elif isinstance(input, str): |
| 226 | input = input.encode(charset) |
| 227 | |
| 228 | return io.BytesIO(input) |
| 229 | |
| 230 | |
| 231 | class Result: |
no test coverage detected