gh-101408: PyObject_GC_Resize should calculate preheader size.#101741
gh-101408: PyObject_GC_Resize should calculate preheader size.#101741corona10 merged 2 commits intopython:mainfrom
Conversation
|
@pablogsal @colesbury Can you please take a look? |
colesbury
left a comment
There was a problem hiding this comment.
This LGTM!
Minor: I don't think this needs backport to 3.10 or 3.11. I think the preheader feature was introduced in 3.12.
Thank you, I will wait for the @pablogsal review too :) |
|
The refleak is not related to this PR, I am finding out the which PR cause the leak. |
|
Thanks a lot for tacking this @corona10 and thanks for the catch @colesbury! I would be more comfortable if we could have a test in |
Okay, I will finalize the PR by end of this weekend. :) |
|
Hi Pablo, I succeeded in adding the test code for the normal PyObject_GC_Resize case. static PyObject *
test_pyobject_gc(PyObject *self, PyObject *Py_UNUSED(ignored))
{
PyTupleObject *obj = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, 3);
obj->ob_item[0] = Py_NewRef(Py_None);
obj->ob_item[1] = Py_NewRef(Py_None);
obj->ob_item[2] = Py_NewRef(Py_None);
if (obj == NULL) {
goto alloc_failed;
}
if (Py_SIZE(obj) != 3) {
Py_DECREF(obj);
PyErr_SetString(PyExc_RuntimeError, "Invalid Py_SIZE(obj)");
return NULL;
}
PyTupleObject *new_obj = PyObject_GC_Resize(PyTupleObject, obj, 6);
if (new_obj == NULL) {
Py_DECREF(obj);
goto alloc_failed;
}
new_obj->ob_item[3] = Py_NewRef(Py_None);
new_obj->ob_item[4] = Py_NewRef(Py_None);
new_obj->ob_item[5] = Py_NewRef(Py_None);
if (Py_SIZE(new_obj) != 6) {
Py_DECREF(new_obj);
PyErr_SetString(PyExc_RuntimeError, "Invalid Py_SIZE(new_obj)");
return NULL;
}
Py_DECREF(new_obj);
Py_RETURN_NONE;
alloc_failed:
PyErr_NoMemory();
return NULL;
} |
|
@pablogsal I think that this PR should be merged before 3.12 is officially released, I will let the issue as opened for test code and merging this PR. |
|
No one wrote code since April, maybe it's time to abandon the idea of having tests and just close the issue? |
Uh oh!
There was an error while loading. Please reload this page.