Fix error handling in Python API, minor cleanup

This commit is contained in:
Florian Märkl 2018-02-23 16:38:32 +01:00 committed by xarkes
parent ec55e40d5e
commit 06dffde0fe
2 changed files with 13 additions and 8 deletions

View File

@ -59,7 +59,7 @@ def launch_ipykernel(argv):
def run_kernel():
app.kernel_class = CutterIPythonKernel
app.log_level = logging.DEBUG
#app.log_level = logging.DEBUG
app.initialize(argv[3:])
app.start()

View File

@ -58,7 +58,9 @@ PyObject *api_internal_launch_ipykernel(PyObject *self, PyObject *args, PyObject
if (!PyArg_ParseTuple(args, "O", &argvListObject)
|| !PyList_Check(argvListObject))
{
qWarning() << "Invalid args passed to api_internal_launch_ipykernel().";
const char *msg = "Invalid args passed to api_internal_launch_ipykernel().";
qWarning() << msg;
PyErr_SetString(PyExc_RuntimeError, msg);
return nullptr;
}
@ -81,7 +83,9 @@ PyObject *api_internal_kernel_interface_send_signal(PyObject *, PyObject *args)
if (!PyArg_ParseTuple(args, "ll", &id, &signum))
{
qWarning() << "Invalid args passed to api_internal_kernel_interface_send_signal().";
const char *msg = "Invalid args passed to api_internal_kernel_interface_send_signal().";
qWarning() << msg;
PyErr_SetString(PyExc_RuntimeError, msg);
return nullptr;
}
@ -100,7 +104,9 @@ PyObject *api_internal_kernel_interface_poll(PyObject *, PyObject *args)
if (!PyArg_ParseTuple(args, "l", &id))
{
qWarning() << "Invalid args passed to api_internal_kernel_interface_poll().";
const char *msg = "Invalid args passed to api_internal_kernel_interface_poll().";
qWarning() << msg;
PyErr_SetString(PyExc_RuntimeError, msg);
return nullptr;
}
@ -130,14 +136,13 @@ PyObject *api_internal_thread_set_async_exc(PyObject *, PyObject *args)
if (!PyArg_ParseTuple(args, "lO", &id, &exc))
{
qWarning() << "Invalid args passed to api_internal_set_async_exc().";
const char *msg = "Invalid args passed to api_internal_thread_set_async_exc().";
qWarning() << msg;
PyErr_SetString(PyExc_RuntimeError, msg);
return nullptr;
}
printf("setasyncexc %ld\n", id);
int ret = PyThreadState_SetAsyncExc(id, exc);
printf("%d threads affected\n", ret);
return PyLong_FromLong(ret);
}