diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-07-11 12:12:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 12:12:36 (GMT) |
commit | f5b76330cfb93e1ad1a77c71dafe719f6a808cec (patch) | |
tree | e0b45fff0dbbca680928e6d87d660ededb653798 /Modules | |
parent | 1fdc35ef519855e1b69addf43af74f3ac7f37a6f (diff) | |
download | cpython-f5b76330cfb93e1ad1a77c71dafe719f6a808cec.zip cpython-f5b76330cfb93e1ad1a77c71dafe719f6a808cec.tar.gz cpython-f5b76330cfb93e1ad1a77c71dafe719f6a808cec.tar.bz2 |
GH-94736: Fix _multiprocessing.SemLock subclassing (#94738)
* fix allocator and deallocator
* 📜🤖 Added by blurb_it.
* code review
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_multiprocessing/semaphore.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c index 8607476..f5fd325 100644 --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -454,9 +454,7 @@ static PyObject * newsemlockobject(PyTypeObject *type, SEM_HANDLE handle, int kind, int maxvalue, char *name) { - SemLockObject *self; - - self = PyObject_New(SemLockObject, type); + SemLockObject *self = (SemLockObject *)type->tp_alloc(type, 0); if (!self) return NULL; self->handle = handle; @@ -573,7 +571,7 @@ semlock_dealloc(SemLockObject* self) if (self->handle != SEM_FAILED) SEM_CLOSE(self->handle); PyMem_Free(self->name); - PyObject_Free(self); + Py_TYPE(self)->tp_free((PyObject*)self); } /*[clinic input] |