We generally want to use the "disabled hint" more often (see T76261), which
is a red text in tooltips that explains why a button is disabled. So far this can't
be done from Python at all. This is a first step to get it supported.
This is a low-effort attempt, but I think it's a reasonable way to go about it.
To set the hint, in a poll method, Python operators can set it like this:
context.operator_poll_message = "Can't do this, because of reasons" return False
The string is stored as copy in an allocated buffer. Not sure if this will work
with translations though, ie obtaining the string with IFACE_().