mirror of https://github.com/python/cpython
Issue #3299: fix thread.allocate_lock() error handler, replace PyObject_Del()
by Py_DECREF() to fix a crash in pydebug mode.
This commit is contained in:
parent
9e220be19d
commit
c951d56f9a
|
@ -27,14 +27,15 @@ typedef struct {
|
||||||
static void
|
static void
|
||||||
lock_dealloc(lockobject *self)
|
lock_dealloc(lockobject *self)
|
||||||
{
|
{
|
||||||
assert(self->lock_lock);
|
|
||||||
if (self->in_weakreflist != NULL)
|
if (self->in_weakreflist != NULL)
|
||||||
PyObject_ClearWeakRefs((PyObject *) self);
|
PyObject_ClearWeakRefs((PyObject *) self);
|
||||||
/* Unlock the lock so it's safe to free it */
|
if (self->lock_lock != NULL) {
|
||||||
PyThread_acquire_lock(self->lock_lock, 0);
|
/* Unlock the lock so it's safe to free it */
|
||||||
PyThread_release_lock(self->lock_lock);
|
PyThread_acquire_lock(self->lock_lock, 0);
|
||||||
|
PyThread_release_lock(self->lock_lock);
|
||||||
PyThread_free_lock(self->lock_lock);
|
|
||||||
|
PyThread_free_lock(self->lock_lock);
|
||||||
|
}
|
||||||
PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,9 +166,9 @@ newlockobject(void)
|
||||||
self->lock_lock = PyThread_allocate_lock();
|
self->lock_lock = PyThread_allocate_lock();
|
||||||
self->in_weakreflist = NULL;
|
self->in_weakreflist = NULL;
|
||||||
if (self->lock_lock == NULL) {
|
if (self->lock_lock == NULL) {
|
||||||
PyObject_Del(self);
|
Py_DECREF(self);
|
||||||
self = NULL;
|
|
||||||
PyErr_SetString(ThreadError, "can't allocate lock");
|
PyErr_SetString(ThreadError, "can't allocate lock");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue