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

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixes for PyStackRefs in debug builds.
  • Loading branch information
efimov-mikhail committed Oct 1, 2025
commit e0ea1b1be7495417fc0872d1665c2d4689ea42d1
14 changes: 14 additions & 0 deletions Include/internal/pycore_stackref.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ static const _PyStackRef PyStackRef_ERROR = { .index = 2 };

#define INITIAL_STACKREF_INDEX 10

static inline _PyStackRef
PyStackRef_Wrap(void *ptr)
{
assert(ptr != NULL);
return (_PyStackRef){ .index = (uint64_t)ptr };
Comment thread
sergey-miryanov marked this conversation as resolved.
}

static inline void *
PyStackRef_Unwrap(_PyStackRef ref)
{
return (void *)(ref.index);
}

static inline int
PyStackRef_IsNull(_PyStackRef ref)
{
Expand Down Expand Up @@ -151,6 +164,7 @@ _PyStackRef_FromPyObjectSteal(PyObject *obj, const char *filename, int linenumbe
static inline _PyStackRef
_PyStackRef_FromPyObjectBorrow(PyObject *obj, const char *filename, int linenumber)
{
Py_INCREF(obj);
Comment thread
efimov-mikhail marked this conversation as resolved.
Outdated
return _Py_stackref_create(obj, filename, linenumber);
}
#define PyStackRef_FromPyObjectBorrow(obj) _PyStackRef_FromPyObjectBorrow(_PyObject_CAST(obj), __FILE__, __LINE__)
Expand Down
Loading