[Python-Dev] Py_DECREF causes spurious gcc warning

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Wed Dec 17 18:39:48 EST 2003


> From: Edward C. Jones
> 
> I use Gentoo 1.4 Linux with gcc 3.2.2. The C program given 
> below gives 
> the following compiler message:
> 
> silly.c: In function `silly':
> silly.c:5: warning: suggest explicit braces to avoid ambiguous `else'
> 
> -----------------------
> #include </usr/local/include/python2.3/Python.h>
> 
> static PyObject* silly(PyObject* obj, PyObject *args)
> {
>      if (1)
>          Py_DECREF(Py_None);

If I were you, I would pay attention to the warning.

> I, of course, just added braces.

If you mean you changed it to:

 static PyObject* silly(PyObject* obj, PyObject *args)
 {
      if (1)
      {
          Py_DECREF(Py_None);
      }

then I would say that's the right thing to do - all the time, in all code.

Tim Delaney



More information about the Python-Dev mailing list