File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -562,11 +562,14 @@ next ? next->flags.blocked : 0)
562
562
/* make sure that locks live longer than their threads */
563
563
564
564
static void
565
- destruct_lock (PyThread_type_lock lock )
565
+ destruct_lock (PyObject * capsule )
566
566
{
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
+ }
570
573
}
571
574
572
575
static PyObject *
@@ -577,10 +580,10 @@ new_lock(void)
577
580
lock = PyThread_allocate_lock ();
578
581
if (lock == NULL ) return NULL ;
579
582
580
- return PyCObject_FromVoidPtr (lock , destruct_lock );
583
+ return PyCapsule_New (lock , 0 , destruct_lock );
581
584
}
582
585
583
- #define get_lock (obj ) PyCObject_AsVoidPtr (obj)
586
+ #define get_lock (obj ) PyCapsule_GetPointer (obj, 0 )
584
587
585
588
#define acquire_lock (lock , flag ) PyThread_acquire_lock(get_lock(lock), flag)
586
589
#define release_lock (lock ) PyThread_release_lock(get_lock(lock))
You can’t perform that action at this time.
0 commit comments