Returns the default stream encoding if not found.
(stream: t.IO[t.Any])
| 46 | |
| 47 | |
| 48 | def get_best_encoding(stream: t.IO[t.Any]) -> str: |
| 49 | """Returns the default stream encoding if not found.""" |
| 50 | rv = getattr(stream, "encoding", None) or sys.getdefaultencoding() |
| 51 | if is_ascii_encoding(rv): |
| 52 | return "utf-8" |
| 53 | return rv |
| 54 | |
| 55 | |
| 56 | class _NonClosingTextIOWrapper(io.TextIOWrapper): |
no test coverage detected