Add PyUnicodeWriter API by vstinner · Pull Request #95 · python/pythoncapi-compat
#if PY_VERSION_HEX < 0x030E0000 && PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION) // snip PyErr_Format(PyExc_TypeError, "expect str, not %T", str);
I did not experience the issue myself, but I think the %T format was introduced in gha-116839 (PEP-737), so may not be available on all versions of CPython?