Check for type consistency for `PyUnicodeError` API

Feature or enhancement

Proposal:

This is a follow-up to #123380 (comment).

The idea is to add assertion type-checks when calling helper functions on unicode objects:

    assert(PyObject_TypeCheck(exc, (PyTypeObject*)&PyExc_UnicodeError));

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs