30 PyGILState_STATE gilstate = PyGILState_Ensure();
32 PyObject *py_args =
static_cast<PyObject *
>(user_data);
33 PyObject *py_func_or_msg = PyTuple_GET_ITEM(py_args, 0);
37 if (PyUnicode_Check(py_func_or_msg)) {
39 const char *msg_src = PyUnicode_AsUTF8AndSize(py_func_or_msg, &msg_len);
43 PyObject *py_args_after_first = PyTuple_GetSlice(py_args, 1, PY_SSIZE_T_MAX);
44 PyObject *py_msg = PyObject_CallObject(py_func_or_msg, py_args_after_first);
45 Py_DECREF(py_args_after_first);
50 if (py_msg ==
nullptr) {
54 if (py_msg == Py_None) {
57 else if (PyUnicode_Check(py_msg)) {
58 Py_ssize_t msg_src_len;
59 const char *msg_src = PyUnicode_AsUTF8AndSize(py_msg, &msg_src_len);
63 PyErr_Format(PyExc_TypeError,
64 "poll_message_set(function, ...): expected string or None, got %.200s",
65 Py_TYPE(py_msg)->tp_name);
77 PyGILState_Release(gilstate);
102 const Py_ssize_t args_len = PyTuple_GET_SIZE(args);
104 PyErr_SetString(PyExc_ValueError,
105 "poll_message_set(message, ...): requires a message argument");
109 PyObject *py_func_or_msg = PyTuple_GET_ITEM(args, 0);
111 if (PyUnicode_Check(py_func_or_msg)) {
113 PyErr_SetString(PyExc_ValueError,
114 "poll_message_set(message): does not support additional arguments");
118 else if (PyCallable_Check(py_func_or_msg)) {
122 PyErr_Format(PyExc_TypeError,
123 "poll_message_set(message, ...): "
124 "expected at least 1 string or callable argument, got %.200s",
125 Py_TYPE(py_func_or_msg)->tp_name);
133 params.user_data = Py_NewRef(args);
void CTX_wm_operator_poll_msg_set_dynamic(bContext *C, const bContextPollMsgDyn_Params *params)
PyDoc_STRVAR(BPY_rna_operator_poll_message_set_doc, ".. classmethod:: poll_message_set(message, *args)\n" "\n" " Set the message to show in the tool-tip when poll fails.\n" "\n" " When message is callable, " "additional user defined positional arguments are passed to the message function.\n" "\n" " :arg message: The message or a function that returns the message.\n" " :type message: str | Callable[[Any, ...], str | None]\n")