Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ability to handle uncaught exceptions

Added Loop.excepthook a la sys.excepthook
All unhandled exceptions will be printed (traceback included) unless
Loop.excepthook is set to a function that gets type, value and traceback
arguments, in which case that function is called
  • Loading branch information...
commit 2ffd2a0eccea8ca7c487aa8bc69f5bf608ffc01f 1 parent 4fa7032
Saúl Ibarra Corretgé authored
2  src/async.c
View
@@ -16,7 +16,7 @@ on_async_callback(uv_async_t *async, int status)
result = PyObject_CallFunctionObjArgs(self->callback, self, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
2  src/check.c
View
@@ -16,7 +16,7 @@ on_check_callback(uv_check_t *handle, int status)
result = PyObject_CallFunctionObjArgs(self->callback, self, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
54 src/fs.c
View
@@ -141,8 +141,7 @@ process_stat(uv_fs_t* req, PyObject **path, PyObject **stat_data, PyObject **err
*stat_data = PyStructSequence_New(&StatResultType);
if (!stat_data) {
- PyErr_NoMemory();
- PyErr_WriteUnraisable(Py_None);
+ PyErr_Clear();
Py_DECREF(*path);
Py_DECREF(*errorno);
*path = NULL;
@@ -167,7 +166,7 @@ stat_cb(uv_fs_t* req) {
if (path && stat_data && errorno) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, stat_data, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(stat_data);
@@ -212,7 +211,7 @@ unlink_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -255,7 +254,7 @@ mkdir_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -298,7 +297,7 @@ rmdir_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -341,7 +340,7 @@ rename_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -384,7 +383,7 @@ chmod_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -427,7 +426,7 @@ link_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -470,7 +469,7 @@ symlink_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -514,7 +513,7 @@ readlink_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -557,7 +556,7 @@ chown_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -608,7 +607,7 @@ open_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, fd, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(fd);
@@ -652,7 +651,7 @@ close_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -708,7 +707,7 @@ read_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(req_data->callback, loop, path, read_data, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(req_data->callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(read_data);
@@ -764,7 +763,7 @@ write_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(req_data->callback, loop, path, bytes_written, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(req_data->callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(bytes_written);
@@ -810,7 +809,7 @@ fsync_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -853,7 +852,7 @@ ftruncate_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -894,8 +893,7 @@ process_readdir(uv_fs_t* req, PyObject **path, PyObject **files, PyObject **erro
Py_INCREF(Py_None);
*files = PyList_New(0);
if (!files) {
- PyErr_NoMemory();
- PyErr_WriteUnraisable(Py_None);
+ PyErr_Clear();
*files = Py_None;
Py_INCREF(Py_None);
} else {
@@ -924,7 +922,7 @@ readdir_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, files, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(files);
@@ -975,7 +973,7 @@ sendfile_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, bytes_written, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(bytes_written);
@@ -1018,7 +1016,7 @@ utime_cb(uv_fs_t* req) {
result = PyObject_CallFunctionObjArgs(callback, loop, path, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(path);
@@ -2456,7 +2454,7 @@ on_fsevent_callback(uv_fs_event_t *handle, const char *filename, int events, int
result = PyObject_CallFunctionObjArgs(self->callback, self, py_filename, py_events, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_events);
@@ -2669,8 +2667,7 @@ on_fspoll_callback(uv_fs_poll_t *handle, int status, const uv_statbuf_t *prev, c
Py_INCREF(Py_None);
prev_stat_data = PyStructSequence_New(&StatResultType);
if (!prev_stat_data) {
- PyErr_NoMemory();
- PyErr_WriteUnraisable(Py_None);
+ PyErr_Clear();
prev_stat_data = Py_None;
Py_INCREF(Py_None);
} else {
@@ -2678,8 +2675,7 @@ on_fspoll_callback(uv_fs_poll_t *handle, int status, const uv_statbuf_t *prev, c
}
curr_stat_data = PyStructSequence_New(&StatResultType);
if (!curr_stat_data) {
- PyErr_NoMemory();
- PyErr_WriteUnraisable(Py_None);
+ PyErr_Clear();
curr_stat_data = Py_None;
Py_INCREF(Py_None);
} else {
@@ -2689,7 +2685,7 @@ on_fspoll_callback(uv_fs_poll_t *handle, int status, const uv_statbuf_t *prev, c
result = PyObject_CallFunctionObjArgs(self->callback, self, prev_stat_data, curr_stat_data, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
2  src/handle.c
View
@@ -13,7 +13,7 @@ on_handle_close(uv_handle_t *handle)
if (self->on_close_cb) {
result = PyObject_CallFunctionObjArgs(self->on_close_cb, self, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->on_close_cb);
+ handle_uncaught_exception(self->loop);
}
Py_XDECREF(result);
}
2  src/idle.c
View
@@ -16,7 +16,7 @@ on_idle_callback(uv_idle_t *handle, int status)
result = PyObject_CallFunctionObjArgs(self->callback, self, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
41 src/loop.c
View
@@ -27,6 +27,7 @@ new_loop(PyTypeObject *type, PyObject *args, PyObject *kwargs, int is_default)
default_loop->uv_loop->data = (void *)default_loop;
default_loop->is_default = 1;
default_loop->weakreflist = NULL;
+ default_loop->excepthook_cb = NULL;
Py_AtExit(_loop_cleanup);
}
Py_INCREF(default_loop);
@@ -40,6 +41,7 @@ new_loop(PyTypeObject *type, PyObject *args, PyObject *kwargs, int is_default)
self->uv_loop->data = (void *)self;
self->is_default = 0;
self->weakreflist = NULL;
+ self->excepthook_cb = NULL;
return (PyObject *)self;
}
}
@@ -52,7 +54,7 @@ Loop_func_run(Loop *self)
uv_run(self->uv_loop);
Py_END_ALLOW_THREADS
if (PyErr_Occurred()) {
- PyErr_WriteUnraisable(Py_None);
+ handle_uncaught_exception(self);
}
Py_RETURN_NONE;
}
@@ -67,7 +69,7 @@ Loop_func_run_once(Loop *self)
r = uv_run_once(self->uv_loop);
Py_END_ALLOW_THREADS
if (PyErr_Occurred()) {
- PyErr_WriteUnraisable(Py_None);
+ handle_uncaught_exception(self);
}
return PyBool_FromLong((long)r);
}
@@ -98,7 +100,8 @@ walk_cb(uv_handle_t* handle, void* arg)
Py_INCREF(obj);
result = PyObject_CallFunctionObjArgs(callback, obj, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ /* TODO: check this... */
+ handle_uncaught_exception(((Handle *)obj)->loop);
}
Py_DECREF(obj);
Py_XDECREF(result);
@@ -232,6 +235,37 @@ Loop_dict_set(Loop *self, PyObject* val, void* c)
}
+static PyObject*
+Loop_excepthook_get(Loop *self, void* c)
+{
+ UNUSED_ARG(c);
+ return self->excepthook_cb;
+}
+
+
+static int
+Loop_excepthook_set(Loop *self, PyObject* val, void* c)
+{
+ PyObject* tmp;
+
+ UNUSED_ARG(c);
+
+ if (val == NULL) {
+ PyErr_SetString(PyExc_TypeError, "excepthook may not be deleted");
+ return -1;
+ }
+ if (val != Py_None && !PyCallable_Check(val)) {
+ PyErr_SetString(PyExc_TypeError, "a callable or None is required");
+ return -1;
+ }
+ tmp = self->excepthook_cb;
+ Py_INCREF(val);
+ self->excepthook_cb = val;
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+
static PyMethodDef
Loop_tp_methods[] = {
{ "run", (PyCFunction)Loop_func_run, METH_NOARGS, "Run the event loop." },
@@ -248,6 +282,7 @@ static PyGetSetDef Loop_tp_getsets[] = {
{"__dict__", (getter)Loop_dict_get, (setter)Loop_dict_set, NULL},
{"active_handles", (getter)Loop_active_handles_get, NULL, "Number of active handles in this loop", NULL},
{"default", (getter)Loop_default_get, NULL, "Is this the default loop?", NULL},
+ {"excepthook", (getter)Loop_excepthook_get, (setter)Loop_excepthook_set, "Loop uncaught exception handler", NULL},
{NULL}
};
6 src/pipe.c
View
@@ -22,7 +22,7 @@ on_pipe_connection(uv_stream_t* server, int status)
result = PyObject_CallFunctionObjArgs(self->on_new_connection_cb, self, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->on_new_connection_cb);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_errorno);
@@ -57,7 +57,7 @@ on_pipe_client_connection(uv_connect_t *req, int status)
result = PyObject_CallFunctionObjArgs(callback, self, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_errorno);
@@ -99,7 +99,7 @@ on_pipe_read2(uv_pipe_t* handle, int nread, uv_buf_t buf, uv_handle_type pending
result = PyObject_CallFunctionObjArgs(self->on_read_cb, self, data, py_pending, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->on_read_cb);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(data);
2  src/poll.c
View
@@ -27,7 +27,7 @@ on_poll_callback(uv_poll_t *handle, int status, int events)
result = PyObject_CallFunctionObjArgs(self->callback, self, py_events, py_errorno,NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
2  src/prepare.c
View
@@ -16,7 +16,7 @@ on_prepare_callback(uv_prepare_t *handle, int status)
result = PyObject_CallFunctionObjArgs(self->callback, self, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
2  src/process.c
View
@@ -198,7 +198,7 @@ on_process_exit(uv_process_t *process, int exit_status, int term_signal)
if (self->on_exit_cb != Py_None) {
result = PyObject_CallFunctionObjArgs(self->on_exit_cb, self, py_exit_status, py_term_signal, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->on_exit_cb);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_exit_status);
66 src/pyuv.h
View
@@ -90,6 +90,7 @@ typedef int Bool;
/* Loop */
typedef struct {
PyObject_HEAD
+ PyObject *excepthook_cb;
PyObject *weakreflist;
PyObject *dict;
uv_loop_t *uv_loop;
@@ -525,6 +526,71 @@ pyuv_guess_ip_family(char *ip, int *address_type)
}
+/* handle uncausht exception in a callback */
+static INLINE void
+handle_uncaught_exception(Loop *loop)
+{
+ PyObject *type, *val, *tb, *result;
+
+ ASSERT(loop);
+ ASSERT(PyErr_Occurred());
+
+ PyErr_Fetch(&type, &val, &tb);
+ PyErr_NormalizeException(&type, &val, &tb);
+ if (!val) {
+ val = Py_None;
+ Py_INCREF(Py_None);
+ }
+ if (!tb) {
+ tb = Py_None;
+ Py_INCREF(Py_None);
+ }
+
+ if (loop->excepthook_cb != NULL && loop->excepthook_cb != Py_None) {
+ result = PyObject_CallFunctionObjArgs(loop->excepthook_cb, type, val, tb, NULL);
+ Py_XDECREF(result);
+ } else {
+ PyErr_Display(type, val, tb);
+ }
+
+ Py_DECREF(type);
+ Py_DECREF(val);
+ Py_DECREF(tb);
+
+ /* just in case*/
+ PyErr_Clear();
+}
+
+
+/* print uncausht exception */
+static INLINE void
+print_uncaught_exception(void)
+{
+ PyObject *type, *val, *tb;
+
+ ASSERT(PyErr_Occurred());
+
+ PyErr_Fetch(&type, &val, &tb);
+ PyErr_NormalizeException(&type, &val, &tb);
+ if (!val) {
+ val = Py_None;
+ Py_INCREF(Py_None);
+ }
+ if (!tb) {
+ tb = Py_None;
+ Py_INCREF(Py_None);
+ }
+
+ PyErr_Display(type, val, tb);
+
+ Py_DECREF(type);
+ Py_DECREF(val);
+ Py_DECREF(tb);
+
+ /* just in case*/
+ PyErr_Clear();
+}
+
#endif
2  src/signal.c
View
@@ -15,7 +15,7 @@ on_signal_callback(uv_signal_t *handle, int signum)
result = PyObject_CallFunctionObjArgs(self->callback, self, PyInt_FromLong((long)signum), NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
6 src/stream.c
View
@@ -43,7 +43,7 @@ on_stream_shutdown(uv_shutdown_t* req, int status)
}
result = PyObject_CallFunctionObjArgs(callback, self, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_errorno);
@@ -84,7 +84,7 @@ on_stream_read(uv_stream_t* handle, int nread, uv_buf_t buf)
result = PyObject_CallFunctionObjArgs(self->on_read_cb, self, data, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->on_read_cb);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(data);
@@ -130,7 +130,7 @@ on_stream_write(uv_write_t* req, int status)
}
result = PyObject_CallFunctionObjArgs(callback, self, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_errorno);
4 src/tcp.c
View
@@ -23,7 +23,7 @@ on_tcp_connection(uv_stream_t* server, int status)
result = PyObject_CallFunctionObjArgs(self->on_new_connection_cb, self, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->on_new_connection_cb);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_errorno);
@@ -58,7 +58,7 @@ on_tcp_client_connection(uv_connect_t *req, int status)
result = PyObject_CallFunctionObjArgs(callback, self, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_errorno);
4 src/threadpool.c
View
@@ -26,7 +26,7 @@ threadpool_work_cb(uv_work_t *req)
PyErr_NormalizeException(&err_type, &err_value, &err_tb);
error = PyTuple_New(3);
if (!error) {
- PyErr_WriteUnraisable(data->work_cb);
+ PyErr_Clear();
error = Py_None;
Py_INCREF(Py_None);
} else {
@@ -73,7 +73,7 @@ threadpool_after_work_cb(uv_work_t *req)
if (data->after_work_cb) {
result = PyObject_CallFunctionObjArgs(data->after_work_cb, data->result, data->error, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(data->after_work_cb);
+ print_uncaught_exception();
}
Py_XDECREF(result);
}
2  src/timer.c
View
@@ -16,7 +16,7 @@ on_timer_callback(uv_timer_t *timer, int status)
result = PyObject_CallFunctionObjArgs(self->callback, self, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
4 src/udp.c
View
@@ -67,7 +67,7 @@ on_udp_read(uv_udp_t* handle, int nread, uv_buf_t buf, struct sockaddr* addr, un
result = PyObject_CallFunctionObjArgs(self->on_read_cb, self, address_tuple, data, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(self->on_read_cb);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(address_tuple);
@@ -115,7 +115,7 @@ on_udp_send(uv_udp_send_t* req, int status)
}
result = PyObject_CallFunctionObjArgs(callback, self, py_errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(((Handle *)self)->loop);
}
Py_XDECREF(result);
Py_DECREF(py_errorno);
10 src/util.c
View
@@ -320,8 +320,6 @@ getaddrinfo_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* res)
dns_result = PyList_New(0);
if (!dns_result) {
- PyErr_NoMemory();
- PyErr_WriteUnraisable(Py_None);
errorno = PyInt_FromLong((long)UV_ENOMEM);
dns_result = Py_None;
Py_INCREF(Py_None);
@@ -331,15 +329,13 @@ getaddrinfo_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* res)
for (ptr = res; ptr; ptr = ptr->ai_next) {
addr = makesockaddr(ptr->ai_addr, ptr->ai_addrlen);
if (!addr) {
- PyErr_NoMemory();
- PyErr_WriteUnraisable(callback);
+ PyErr_Clear();
break;
}
item = PyStructSequence_New(&AddrinfoResultType);
if (!item) {
- PyErr_NoMemory();
- PyErr_WriteUnraisable(callback);
+ PyErr_Clear();
break;
}
PyStructSequence_SET_ITEM(item, 0, PyInt_FromLong((long)ptr->ai_family));
@@ -357,7 +353,7 @@ getaddrinfo_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* res)
callback:
result = PyObject_CallFunctionObjArgs(callback, dns_result, errorno, NULL);
if (result == NULL) {
- PyErr_WriteUnraisable(callback);
+ handle_uncaught_exception(loop);
}
Py_XDECREF(result);
Py_DECREF(dns_result);
Please sign in to comment.
Something went wrong with that request. Please try again.