This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: doc bug in Lock.acquire
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, cperkins, georg.brandl
Priority: normal Keywords:

Created on 2005-05-27 14:04 by cperkins, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg25427 - (view) Author: Chris Perkins (cperkins) Date: 2005-05-27 14:04
The docs for the acquire method in both the thread and
threading modules are incorrect.  They describe an old
(insane) version that returned None when called with no
argument. It appears that acquire is now sane, and
always returns True or False.

msg25428 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-05-31 09:33
Logged In: YES 
user_id=1188172

It certainly seems that there is a code path in Lock.acquire
that can return None, as the following excerpt from
Modules/threadmodule.c shows:

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);
}

Nevertheless, a_lock.acquire() still returns true.
msg25429 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2005-06-02 12:37
Logged In: YES 
user_id=11375

I think the (args==NULL) code path is vestigial and can no longer be 
executed, because the PyArg_ParseTuple call will fail if args is NULL.
msg25430 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2005-06-02 17:01
Logged In: YES 
user_id=11375

I've changed the docs on both the HEAD and 2.4-maint branches to only 
describe the True/False return values.  Thanks for your report!
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42024
2005-05-27 14:04:30cperkinscreate