xcp.compat

Helper module for setting up binary or UTF-8 I/O for Popen and open in Python 3.6 and newer

xcp.compat.open_defaults_for_utf8_text(args: tuple[Any, ...] | None, kwargs: Any) tuple[str, Any][source]

Setup keyword arguments for UTF-8 text mode with codec error handler to replace chars

xcp.compat.open_textfile(filename: str, mode: str, encoding: str = 'utf-8', **kwargs: Any) IO[str][source]

For best type checking and type inference, wrap open_with_codec_handling returning IO[str]

xcp.compat.open_with_codec_handling(filename: str, mode: str = 'r', encoding: str = 'utf-8', **kwargs: Any) IO[Any][source]

Helper for open(): Handle UTF-8: Default to encoding=”utf-8”, errors=”replace” for Py3