Skip to content

Commit 3a12d18

Browse files
committed
Add PyStackRef_IsMortal
1 parent 49d0d42 commit 3a12d18

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Include/internal/pycore_stackref.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,20 @@ PyStackRef_HasCount(_PyStackRef ref)
267267
return ref.bits & Py_TAG_REFCNT;
268268
}
269269

270+
/* Does this ref have an embedded refcount and refer to a mortal object (NULL is not mortal) */
270271
static inline bool
271272
PyStackRef_HasCountAndMortal(_PyStackRef ref)
272273
{
273274
return (ref.bits & Py_TAG_BITS) == Py_TAG_REFCNT;
274275
}
275276

277+
/* Does this ref refer to a mortal object (NULL is not mortal) */
278+
static inline bool
279+
PyStackRef_IsMortal(_PyStackRef ref)
280+
{
281+
return (ref.bits & Py_TAG_BITS) != Py_TAG_IMMORTAL;
282+
}
283+
276284
static inline PyObject *
277285
PyStackRef_AsPyObjectBorrow(_PyStackRef ref)
278286
{

0 commit comments

Comments
 (0)