[patch][python] Fix crash in some no-argument methods

John (J5) Palmieri johnp at redhat.com
Wed Feb 21 06:59:45 PST 2007


Looks good.  Commit away.

On Wed, 2007-02-21 at 12:32 +0000, Simon McVittie wrote:
> >From 8dce2df1ceacffb2aa6e2cc8b1d4b58ee95ac5b1 Mon Sep 17 00:00:00 2001
> From: Simon McVittie <simon.mcvittie at collabora.co.uk>
> Date: Wed, 21 Feb 2007 12:31:15 +0000
> Subject: [PATCH] Don't examine args for functions declared METH_NOARGS.
> It's not guaranteed to be non-NULL, and Python checks there are no arguments
> so we don't have to.
> ---
>  _dbus_bindings/conn-methods.c |    9 +++------
>  1 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/_dbus_bindings/conn-methods.c b/_dbus_bindings/conn-methods.c
> index 09fc873..dae1816 100644
> --- a/_dbus_bindings/conn-methods.c
> +++ b/_dbus_bindings/conn-methods.c
> @@ -226,10 +226,9 @@ PyDoc_STRVAR(Connection_close__doc__,
>  "close()\n\n"
>  "Close the connection.");
>  static PyObject *
> -Connection_close (Connection *self, PyObject *args)
> +Connection_close (Connection *self, PyObject *args UNUSED)
>  {
>      TRACE(self);
> -    if (!PyArg_ParseTuple(args, ":close")) return NULL;
>      /* Because the user explicitly asked to close the connection, we'll even
>      let them close shared connections. */
>      if (self->conn) {
> @@ -244,13 +243,12 @@ PyDoc_STRVAR(Connection_get_is_connected__doc__,
>  "get_is_connected() -> bool\n\n"
>  "Return true if this Connection is connected.\n");
>  static PyObject *
> -Connection_get_is_connected (Connection *self, PyObject *args)
> +Connection_get_is_connected (Connection *self, PyObject *args UNUSED)
>  {
>      dbus_bool_t ret;
>  
>      TRACE(self);
>      DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
> -    if (!PyArg_ParseTuple(args, ":get_is_connected")) return NULL;
>      Py_BEGIN_ALLOW_THREADS
>      ret = dbus_connection_get_is_connected(self->conn);
>      Py_END_ALLOW_THREADS
> @@ -261,13 +259,12 @@ PyDoc_STRVAR(Connection_get_is_authenticated__doc__,
>  "get_is_authenticated() -> bool\n\n"
>  "Return true if this Connection was ever authenticated.\n");
>  static PyObject *
> -Connection_get_is_authenticated (Connection *self, PyObject *args)
> +Connection_get_is_authenticated (Connection *self, PyObject *args UNUSED)
>  {
>      dbus_bool_t ret;
>  
>      TRACE(self);
>      DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
> -    if (!PyArg_ParseTuple(args, ":get_is_authenticated")) return NULL;
>      Py_BEGIN_ALLOW_THREADS
>      ret = dbus_connection_get_is_authenticated(self->conn);
>      Py_END_ALLOW_THREADS
-- 
John (J5) Palmieri <johnp at redhat.com>



More information about the dbus mailing list