8000 Replace the deprecated PyCObject api with PyCapsule. · stackless-dev/stackless_historic@c7229b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit c7229b7

Browse files
author
kristjan.jonsson
committed
Replace the deprecated PyCObject api with PyCapsule.
git-svn-id: http://svn.python.org/projects/stackless/trunk@82395 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 86930be commit c7229b7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Stackless/module/scheduling.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,14 @@ next ? next->flags.blocked : 0)
562562
/* make sure that locks live longer than their threads */
563563

564564
static void
565-
destruct_lock(PyThread_type_lock lock)
565+
destruct_lock(PyObject *capsule)
566566
{
567-
PyThread_acquire_lock(lock, 0);
568-
PyThread_release_lock(lock);
569-
PyThread_free_lock(lock);
567+
PyThread_type_lock lock = PyCapsule_GetPointer(capsule, 0);
568+
if (lock) {
569+
PyThread_acquire_lock(lock, 0);
570+
PyThread_release_lock(lock);
571+
PyThread_free_lock(lock);
572+
}
570573
}
571574

572575
static PyObject *
@@ -577,10 +580,10 @@ new_lock(void)
577580
lock = PyThread_allocate_lock();
578581
if (lock == NULL) return NULL;
579582

580-
return PyCObject_FromVoidPtr(lock, destruct_lock);
583+
return PyCapsule_New(lock, 0, destruct_lock);
581584
}
582585

583-
#define get_lock(obj) PyCObject_AsVoidPtr(obj)
586+
#define get_lock(obj) PyCapsule_GetPointer(obj, 0)
584587

585588
#define acquire_lock(lock, flag) PyThread_acquire_lock(get_lock(lock), flag)
586589
#define release_lock(lock) PyThread_release_lock(get_lock(lock))

0 commit comments

Comments
 (0)
0