Skip to content

Commit 849369d

Browse files
Format fixes, changes in entry struct
1 parent e615d9f commit 849369d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Python/stackrefs.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ typedef struct _table_entry {
1919
int linenumber;
2020
const char *filename_borrow;
2121
int linenumber_borrow;
22+
int borrows;
23+
_PyStackRef borrowed_from;
2224
} TableEntry;
2325

2426
TableEntry *
@@ -34,6 +36,8 @@ make_table_entry(PyObject *obj, const char *filename, int linenumber)
3436
result->linenumber = linenumber;
3537
result->filename_borrow = NULL;
3638
result->linenumber_borrow = 0;
39+
result->borrows = 0;
40+
result->borrowed_from = PyStackRef_NULL;
3741
return result;
3842
}
3943

@@ -68,13 +72,12 @@ _Py_stackref_close(_PyStackRef ref, const char *filename, int linenumber)
6872
assert(!PyStackRef_IsError(ref));
6973
PyInterpreterState *interp = PyInterpreterState_Get();
7074
if (ref.index >= interp->next_stackref) {
71-
_Py_FatalErrorFormat(__func__, "Invalid StackRef with ID %" PRIu64 " at %s:%d\n", (void *)ref.index, filename, linenumber);
72-
75+
_Py_FatalErrorFormat(__func__, "Invalid StackRef with ID %" PRIu64 " at %s:%d\n", ref.index, filename, linenumber);
7376
}
7477
PyObject *obj;
7578
if (ref.index < INITIAL_STACKREF_INDEX) {
7679
if (ref.index == 0) {
77-
_Py_FatalErrorFormat(__func__, "Passing NULL to PyStackRef_CLOSE at %s:%d\n", filename, linenumber);
80+
_Py_FatalErrorFormat(__func__, "Passing NULL to _Py_stackref_close at %s:%d\n", filename, linenumber);
7881
}
7982
// Pre-allocated reference to None, False or True -- Do not clear
8083
TableEntry *entry = _Py_hashtable_get(interp->open_stackrefs_table, (void *)ref.index);
@@ -88,10 +91,10 @@ _Py_stackref_close(_PyStackRef ref, const char *filename, int linenumber)
8891
if (entry != NULL) {
8992
_Py_FatalErrorFormat(__func__,
9093
"Double close of ref ID %" PRIu64 " at %s:%d. Referred to instance of %s at %p. Closed at %s:%d\n",
91-
(void *)ref.index, filename, linenumber, entry->classname, entry->obj, entry->filename, entry->linenumber);
94+
ref.index, filename, linenumber, entry->classname, entry->obj, entry->filename, entry->linenumber);
9295
}
9396
#endif
94-
_Py_FatalErrorFormat(__func__, "Invalid StackRef with ID %" PRIu64 "\n", (void *)ref.index);
97+
_Py_FatalErrorFormat(__func__, "Invalid StackRef with ID %" PRIu64 "\n", ref.index);
9598
}
9699
obj = entry->obj;
97100
free(entry);
@@ -143,10 +146,10 @@ _Py_stackref_record_borrow(_PyStackRef ref, const char *filename, int linenumber
143146
if (entry != NULL) {
144147
_Py_FatalErrorFormat(__func__,
145148
"Borrow of closed ref ID %" PRIu64 " at %s:%d. Referred to instance of %s at %p. Closed at %s:%d\n",
146-
(void *)ref.index, filename, linenumber, entry->classname, entry->obj, entry->filename, entry->linenumber);
149+
ref.index, filename, linenumber, entry->classname, entry->obj, entry->filename, entry->linenumber);
147150
}
148151
#endif
149-
_Py_FatalErrorFormat(__func__, "Invalid StackRef with ID %" PRIu64 " at %s:%d\n", (void *)ref.index, filename, linenumber);
152+
_Py_FatalErrorFormat(__func__, "Invalid StackRef with ID %" PRIu64 " at %s:%d\n", ref.index, filename, linenumber);
150153
}
151154
entry->filename_borrow = filename;
152155
entry->linenumber_borrow = linenumber;

0 commit comments

Comments
 (0)