        import codecs
            encoding = %r
            text = %r
            encoder = codecs.getincrementalencoder(encoding)()
            text2 = encoder.encode(text).decode(encoding)
            if text2 != text:
                raise ValueError(f"encoding issue: {text2!a} != {text!a}")
        )