Fix crashes in :meth:`io.TextIOWrapper.reconfigure` when pass invalid arguments, e.g. non-string encoding.