Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68e398d

Browse files
committed
_Py_AddToAllObjects(): remove force parameter
1 parent 48f509b commit 68e398d

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

Include/internal/pycore_object.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ extern void _PyDebug_PrintTotalRefs(void);
297297
#endif
298298

299299
#ifdef Py_TRACE_REFS
300-
extern void _Py_AddToAllObjects(PyObject *op, int force);
300+
extern void _Py_AddToAllObjects(PyObject *op);
301301
extern void _Py_PrintReferences(PyInterpreterState *, FILE *);
302302
extern void _Py_PrintReferenceAddresses(PyInterpreterState *, FILE *);
303303
#endif

Objects/object.c

+9-15
Original file line numberDiff line numberDiff line change
@@ -196,23 +196,17 @@ _PyRefchain_Remove(PyInterpreterState *interp, PyObject *obj)
196196
}
197197

198198

199-
/* Insert op at the front of the list of all objects. If force is true,
200-
* op is added even if _ob_prev and _ob_next are non-NULL already. If
201-
* force is false amd _ob_prev or _ob_next are non-NULL, do nothing.
202-
* force should be true if and only if op points to freshly allocated,
203-
* uninitialized memory, or you've unlinked op from the list and are
204-
* relinking it into the front.
205-
* Note that objects are normally added to the list via _Py_NewReference,
206-
* which is called by PyObject_Init. Not all objects are initialized that
207-
* way, though; exceptions include statically allocated type objects, and
208-
* statically allocated singletons (like Py_True and Py_None).
209-
*/
199+
/* Add an object to the refchain hash table.
200+
*
201+
* Note that objects are normally added to the list by PyObject_Init()
202+
* indirectly. Not all objects are initialized that way, though; exceptions
203+
* include statically allocated type objects, and statically allocated
204+
* singletons (like Py_True and Py_None). */
210205
void
211-
_Py_AddToAllObjects(PyObject *op, int force)
206+
_Py_AddToAllObjects(PyObject *op)
212207
{
213208
PyInterpreterState *interp = _PyInterpreterState_GET();
214-
bool traced = _PyRefchain_IsTraced(interp, op);
215-
if (force || !traced) {
209+
if (!_PyRefchain_IsTraced(interp, op)) {
216210
_PyRefchain_Trace(interp, op);
217211
}
218212
}
@@ -2250,7 +2244,7 @@ new_reference(PyObject *op)
22502244
// Skip the immortal object check in Py_SET_REFCNT; always set refcnt to 1
22512245
op->ob_refcnt = 1;
22522246
#ifdef Py_TRACE_REFS
2253-
_Py_AddToAllObjects(op, 1);
2247+
_Py_AddToAllObjects(op);
22542248
#endif
22552249
}
22562250

Objects/typeobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7508,7 +7508,7 @@ type_ready(PyTypeObject *type, int rerunbuiltin)
75087508
* to get type objects into the doubly-linked list of all objects.
75097509
* Still, not all type objects go through PyType_Ready.
75107510
*/
7511-
_Py_AddToAllObjects((PyObject *)type, 0);
7511+
_Py_AddToAllObjects((PyObject *)type);
75127512
#endif
75137513

75147514
/* Initialize tp_dict: _PyType_IsReady() tests if tp_dict != NULL */

Python/bltinmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3110,7 +3110,7 @@ _PyBuiltin_Init(PyInterpreterState *interp)
31103110
* result, programs leaking references to None and False (etc)
31113111
* couldn't be diagnosed by examining sys.getobjects(0).
31123112
*/
3113-
#define ADD_TO_ALL(OBJECT) _Py_AddToAllObjects((PyObject *)(OBJECT), 0)
3113+
#define ADD_TO_ALL(OBJECT) _Py_AddToAllObjects((PyObject *)(OBJECT))
31143114
#else
31153115
#define ADD_TO_ALL(OBJECT) (void)0
31163116
#endif

Python/hashtable.c

-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ _Py_hashtable_set(_Py_hashtable_t *ht, const void *key, void *value)
226226
assert(entry == NULL);
227227
#endif
228228

229-
230229
entry = ht->alloc.malloc(sizeof(_Py_hashtable_entry_t));
231230
if (entry == NULL) {
232231
/* memory allocation failed */

0 commit comments

Comments
 (0)