Skip to content

Commit bd6ba53

Browse files
Assert in _Py_stackref_set_borrowed_from
1 parent 8c28c68 commit bd6ba53

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Python/stackrefs.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ _Py_stackref_get_borrowed_from(_PyStackRef ref, const char *filename, int linenu
200200
void
201201
_Py_stackref_set_borrowed_from(_PyStackRef ref, _PyStackRef borrowed_from, const char *filename, int linenumber)
202202
{
203-
if (PyStackRef_IsNull(borrowed_from)) {
204-
return;
205-
}
206-
207203
assert(!PyStackRef_IsError(ref));
208204
PyInterpreterState *interp = PyInterpreterState_Get();
209205

@@ -214,6 +210,11 @@ _Py_stackref_set_borrowed_from(_PyStackRef ref, _PyStackRef borrowed_from, const
214210
ref.index, filename, linenumber);
215211
}
216212

213+
assert(PyStackRef_IsNull(entry->borrowed_from));
214+
if (PyStackRef_IsNull(borrowed_from)) {
215+
return;
216+
}
217+
217218
TableEntry *entry_borrowed = _Py_hashtable_get(interp->open_stackrefs_table, (void *)borrowed_from.index);
218219
if (entry_borrowed == NULL) {
219220
_Py_FatalErrorFormat(__func__,

0 commit comments

Comments
 (0)