Here message pass to `to_string` and then to `sys.stderr.write()` `to_string` – returns bytes `sys.stderr.write` receives str `TypeError: write() argument must be str, not bytes`: