Skip to content

Commit 5c621a6

Browse files
committed
Add PyStackRef_Transfer
1 parent a88c6be commit 5c621a6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Include/internal/pycore_stackref.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ extern "C" {
5555

5656
#if !defined(Py_GIL_DISABLED) && defined(Py_STACKREF_DEBUG)
5757

58+
59+
5860
typedef union _PyStackRef {
5961
uint64_t index;
6062
} _PyStackRef;
@@ -147,10 +149,20 @@ _PyStackRef_DUP(_PyStackRef ref, const char *filename, int linenumber)
147149
}
148150
#define PyStackRef_DUP(REF) _PyStackRef_DUP(REF, __FILE__, __LINE__)
149151

152+
static inline _PyStackRef
153+
_PyStackRef_Transfer(_PyStackRef ref, const char *filename, int linenumber)
154+
{
155+
PyObject *obj = _Py_stackref_close(ref);
156+
return _Py_stackref_create(obj, filename, linenumber);
157+
}
158+
#define PyStackRef_Transfer(REF) _PyStackRef_Transfer(REF, __FILE__, __LINE__)
159+
150160
#define PyStackRef_CLOSE_SPECIALIZED(stackref, dealloc) PyStackRef_CLOSE(stackref)
151161

152162
#else
153163

164+
#define PyStackRef_Transfer(REF) (REF)
165+
154166
typedef union _PyStackRef {
155167
uintptr_t bits;
156168
} _PyStackRef;

0 commit comments

Comments
 (0)