def METHOD_NAME(s):
    try:
        encoded_bytes = s.encode('pdfdoc')
    except ValueError as e:
        allowed_errors = [
            "'pdfdoc' codec can't encode character",
            "'pdfdoc' codec can't process Unicode surrogates",
            "'pdfdoc' codec can't encode some characters",
        ]
        if any((allowed in str(e)) for allowed in allowed_errors):
            return
        raise
    else:
        try:
            assert encoded_bytes.decode('pdfdoc') == s, "encode -> decode failed"
        except UnicodeDecodeError as e:
            if "can't decode byte 0x9f" in str(e):
                return
            raise