def _literal_bytes(b):
    """
    convert bytes to printable text.

    backslash and double-quotes will be escaped by
    backslash.
    "hello" -> "hello\\"

    we don't add outter double quotes here, since
    completer also need this function's return value
    to patch completers.

    b'hello' -> "hello"
    b'double"quotes"' -> "double"quotes""
    """
    s = str(b)
    s = s[2:-1]
    s = s.replace("\\'", "'")
    return s
