File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ extern "C" {
1111#include "pycore_object.h" // _PyObject_GC_IS_TRACKED
1212#include "pycore_structs.h" // _PyStackRef
1313
14- /* Check whether an object is eligible for tuple untracking.
15- * `op`: The live object to inspect .
16- * Returns: True for an exact tracked tuple with no NULL or potentially tracked items.
14+ /* Check whether an exact tracked tuple is eligible for untracking.
15+ * `op`: A live exact tuple currently tracked by the GC .
16+ * Returns: True if the tuple has no NULL or potentially tracked items.
1717 */
1818extern bool _PyTuple_CanUntrack (PyObject * op );
1919extern void _PyTuple_MaybeUntrack (PyObject * );
Original file line number Diff line number Diff line change @@ -140,8 +140,8 @@ _PyTuple_CanUntrack(PyObject *op)
140140 PyTupleObject * t ;
141141 Py_ssize_t i , n ;
142142
143- if (! PyTuple_CheckExact (op ) || ! _PyObject_GC_IS_TRACKED ( op ))
144- return false ;
143+ assert ( PyTuple_CheckExact (op ));
144+ assert ( _PyObject_GC_IS_TRACKED ( op )) ;
145145 t = (PyTupleObject * ) op ;
146146 n = Py_SIZE (t );
147147 for (i = 0 ; i < n ; i ++ ) {
@@ -159,6 +159,9 @@ _PyTuple_CanUntrack(PyObject *op)
159159void
160160_PyTuple_MaybeUntrack (PyObject * op )
161161{
162+ if (!PyTuple_CheckExact (op ) || !_PyObject_GC_IS_TRACKED (op )) {
163+ return ;
164+ }
162165 if (_PyTuple_CanUntrack (op )) {
163166 _PyObject_GC_UNTRACK (op );
164167 }
You can’t perform that action at this time.
0 commit comments