def console_to_str(s):
        try:
            return s.decode(console_encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')
From pypa/pip project, pip.backwardwardcompat. License MIT.
dataset/ETHPy150Open tony/tmuxp/tmuxp/_compat.py/console_to_str