-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
gh-140025: Fix queue.SimpleQueue.__sizeof__()
#143137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4d03baf
b2b05ea
205fd00
21014aa
de68f62
654673a
de5b4c7
9e67b66
034a9cd
887af43
7ba914f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -238,6 +238,18 @@ simplequeue_traverse(PyObject *op, visitproc visit, void *arg) | |
| Py_VISIT(Py_TYPE(self)); | ||
| return 0; | ||
| } | ||
| static PyObject * | ||
| simplequeue_sizeof(PyObject *op, PyObject *Py_UNUSED(ignored)) | ||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs a critical section (a lock for the queue). The simplest way is to use "Argument Clinic" like the other functions. Something like: Then run |
||
| simplequeueobject *self = simplequeueobject_CAST(op); | ||
| Py_ssize_t size = Py_TYPE(self)->tp_basicsize; | ||
|
|
||
| if (self->buf.items != NULL) { | ||
| size += (Py_ssize_t)self->buf.items_cap * (Py_ssize_t)sizeof(PyObject *); | ||
| } | ||
|
|
||
| return PyLong_FromSsize_t(size); | ||
| } | ||
|
|
||
| /*[clinic input] | ||
| @classmethod | ||
|
|
@@ -534,6 +546,7 @@ static PyMethodDef simplequeue_methods[] = { | |
| _QUEUE_SIMPLEQUEUE_PUT_METHODDEF | ||
| _QUEUE_SIMPLEQUEUE_PUT_NOWAIT_METHODDEF | ||
| _QUEUE_SIMPLEQUEUE_QSIZE_METHODDEF | ||
| {"__sizeof__", (PyCFunction)simplequeue_sizeof, METH_NOARGS, NULL}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll also need to change this to use the Argument Clinic methoddef (like above). |
||
| {"__class_getitem__", Py_GenericAlias, | ||
| METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, | ||
| {NULL, NULL} /* sentinel */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few changes:
support.calcobjsizesys.getsizeof()instead of calling__sizeof__directly