[Python-Dev] Py_DECREF causes spurious gcc warning (original) (raw)

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Wed Dec 17 20:09:43 EST 2003


From: Skip Montanaro [mailto:skip at pobox.com]

Tim> If you mean you changed it to: Tim> static PyObject* silly(PyObject* obj, PyObject *args) Tim> { Tim> if (1) Tim> { Tim> PyDECREF(PyNone); Tim> } Tim> then I would say that's the right thing to do - all the time, in Tim> all code. Then you also agree we should bracify the Py*REF macros, right?

Maybe, maybe not. In this case, not bracifying the macros revealed what is IMO a poor coding practice. So you could argue that not having the braces there is a Good Thing(TM). However, I do prefer that macros be as self-contained as functions, since when reading them, they look exactly the same.

The problem in the original case is that the if clause does not contain the braces that it should have - and as a result, can lead to ambiguous code (in terms of readability). My opinion is that no matter what code you are writing in C, blocks should be delimited appropriately. That way there's no possibility of confusion.

Fortunately, I get to write the coding standards for my team, so I don't have to put up with anyone else's wrong ideas :)

Tim Delaney



More information about the Python-Dev mailing list