[Python-Dev] Vestigial code in threadmodule?

A.M. Kuchling amk at amk.ca
Thu Jun 2 14:52:05 CEST 2005


Looking at bug #1209880, the following function from threadmodule.c is
referenced.  I think the args==NULL case, which can return None
instead of a Boolean value, can never be reached because
PyArg_ParseTuple() will fail if args==NULL.

Before ripping the args==NULL code out, I wanted to be sure my
analysis is correct; is there some subtlety here I'm missing that
makes args==NULL possible?

--amk

static PyObject *
lock_PyThread_acquire_lock(lockobject *self, PyObject *args)
{
   int i = 1;

   if (!PyArg_ParseTuple(args, "|i:acquire", &i))
      return NULL;

   Py_BEGIN_ALLOW_THREADS
   i = PyThread_acquire_lock(self->lock_lock, i);
   Py_END_ALLOW_THREADS

   if (args == NULL) {
      Py_INCREF(Py_None);
      return Py_None;
   }
   else
      return PyBool_FromLong((long)i);
}


More information about the Python-Dev mailing list