From 20f32c36cdf6f12b54f815c9264a10b2058d982b Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Wed, 21 May 2008 10:43:56 +0000 Subject: Accept None for the child_setup parameter of gobject.spawn_async(). Also * gobject/gobjectmodule.c (pyg_spawn_async): Accept None for the child_setup parameter of gobject.spawn_async(). Also check that it is callable. svn path=/trunk/; revision=780 --- ChangeLog | 6 ++++++ gobject/gobjectmodule.c | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d259e3..c85aa5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-21 Gustavo J. A. M. Carneiro + + * gobject/gobjectmodule.c (pyg_spawn_async): Accept None for the + child_setup parameter of gobject.spawn_async(). Also check that + it is callable. + 2008-04-27 Paul Pogonyshev * gobject/pygenum.c (pyg_enum_richcompare): Fix: raise warning as diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 0f704a3..fa12a03 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -2425,7 +2425,7 @@ pyg_spawn_async(PyObject *unused, PyObject *args, PyObject *kwargs) "standard_output", "standard_error", NULL }; PyObject *pyargv, *pyenvp = NULL; char **argv, **envp = NULL; - PyObject *func = NULL, *user_data = NULL; + PyObject *func = Py_None, *user_data = NULL; char *working_directory = NULL; int flags = 0, _stdin = -1, _stdout = -1, _stderr = -1; PyObject *pystdin = NULL, *pystdout = NULL, *pystderr = NULL; @@ -2507,7 +2507,14 @@ pyg_spawn_async(PyObject *unused, PyObject *args, PyObject *kwargs) } } - if (func) { + if (func != Py_None) { + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, "child_setup parameter must be callable or None"); + g_free(argv); + if (envp) + g_free(envp); + return NULL; + } callback_data = g_new(struct _PyGChildSetupData, 1); callback_data->func = func; callback_data->data = user_data; @@ -2517,12 +2524,14 @@ pyg_spawn_async(PyObject *unused, PyObject *args, PyObject *kwargs) } if (!g_spawn_async_with_pipes(working_directory, argv, envp, flags, - func? _pyg_spawn_async_callback : NULL, + (func != Py_None ? _pyg_spawn_async_callback : NULL), callback_data, &child_pid, standard_input, standard_output, standard_error, &error)) + + { g_free(argv); if (envp) g_free(envp); -- cgit