diff options
author | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2008-05-21 10:43:56 +0000 |
---|---|---|
committer | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2008-05-21 10:43:56 +0000 |
commit | 20f32c36cdf6f12b54f815c9264a10b2058d982b (patch) | |
tree | f32f7062c186da250a254eb8e7223ec8049fa3e7 | |
parent | 486a4d74244dcb7277710b8139f16be46a06492a (diff) | |
download | pygobject-20f32c36cdf6f12b54f815c9264a10b2058d982b.tar.gz pygobject-20f32c36cdf6f12b54f815c9264a10b2058d982b.tar.xz pygobject-20f32c36cdf6f12b54f815c9264a10b2058d982b.zip |
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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | gobject/gobjectmodule.c | 15 |
2 files changed, 18 insertions, 3 deletions
@@ -1,3 +1,9 @@ +2008-05-21 Gustavo J. A. M. Carneiro <gjc@gnome.org> + + * 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 <pogonyshev@gmx.net> * 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); |