Skip to content

Commit 1179f4b

Browse files
authored
bpo-33583: Add note in PyObject_GC_Resize() doc (pythonGH-7021)
1 parent e253752 commit 1179f4b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Doc/c-api/gcsupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Constructors for container types must conform to two rules:
4949
.. c:function:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize)
5050
5151
Resize an object allocated by :c:func:`PyObject_NewVar`. Returns the
52-
resized object or *NULL* on failure.
52+
resized object or *NULL* on failure. *op* must not be tracked by the collector yet.
5353
5454
5555
.. c:function:: void PyObject_GC_Track(PyObject *op)

Modules/gcmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,7 @@ _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
17521752
{
17531753
const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems);
17541754
PyGC_Head *g = AS_GC(op);
1755+
assert(!IS_TRACKED(op));
17551756
if (basicsize > PY_SSIZE_T_MAX - sizeof(PyGC_Head))
17561757
return (PyVarObject *)PyErr_NoMemory();
17571758
g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);

0 commit comments

Comments
 (0)