Commit 3ccc3138 authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub

bpo-33583: Add note in PyObject_GC_Resize() doc (GH-7021)

(cherry picked from commit 1179f4b4)
Co-authored-by: default avatarINADA Naoki <methane@users.noreply.github.com>
parent ea9a0994
...@@ -56,7 +56,7 @@ Constructors for container types must conform to two rules: ...@@ -56,7 +56,7 @@ Constructors for container types must conform to two rules:
.. c:function:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize) .. c:function:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize)
Resize an object allocated by :c:func:`PyObject_NewVar`. Returns the Resize an object allocated by :c:func:`PyObject_NewVar`. Returns the
resized object or *NULL* on failure. resized object or *NULL* on failure. *op* must not be tracked by the collector yet.
.. versionchanged:: 2.5 .. versionchanged:: 2.5
This function used an :c:type:`int` type for *newsize*. This might This function used an :c:type:`int` type for *newsize*. This might
......
...@@ -1539,6 +1539,7 @@ _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems) ...@@ -1539,6 +1539,7 @@ _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
{ {
const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems); const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems);
PyGC_Head *g = AS_GC(op); PyGC_Head *g = AS_GC(op);
assert(!IS_TRACKED(op));
if (basicsize > PY_SSIZE_T_MAX - sizeof(PyGC_Head)) if (basicsize > PY_SSIZE_T_MAX - sizeof(PyGC_Head))
return (PyVarObject *)PyErr_NoMemory(); return (PyVarObject *)PyErr_NoMemory();
g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize); g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment