Skip to content

Commit f5df46d

Browse files
committed
Add a low-level API to access interpreters, for David Beazley.
SF patch #436376.
1 parent 130fb17 commit f5df46d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Include/pystate.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ extern DL_IMPORT(PyThreadState *) _PyThreadState_Current;
100100
#define PyThreadState_GET() (_PyThreadState_Current)
101101
#endif
102102

103+
/* Routines for advanced debuggers, requested by David Beazley.
104+
Don't use unless you know what you are doing! */
105+
DL_IMPORT(PyInterpreterState *) PyInterpreterState_Head(void);
106+
DL_IMPORT(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
107+
DL_IMPORT(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
108+
DL_IMPORT(PyThreadState *) PyThreadState_Next(PyThreadState *);
109+
103110
#ifdef __cplusplus
104111
}
105112
#endif

Python/pystate.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,28 @@ PyThreadState_GetDict(void)
264264
_PyThreadState_Current->dict = PyDict_New();
265265
return _PyThreadState_Current->dict;
266266
}
267+
268+
269+
/* Routines for advanced debuggers, requested by David Beazley.
270+
Don't use unless you know what you are doing! */
271+
272+
PyInterpreterState *
273+
PyInterpreterState_Head(void)
274+
{
275+
return interp_head;
276+
}
277+
278+
PyInterpreterState *
279+
PyInterpreterState_Next(PyInterpreterState *interp) {
280+
return interp->next;
281+
}
282+
283+
PyThreadState *
284+
PyInterpreterState_ThreadHead(PyInterpreterState *interp) {
285+
return interp->tstate_head;
286+
}
287+
288+
PyThreadState *
289+
PyThreadState_Next(PyThreadState *tstate) {
290+
return tstate->next;
291+
}

0 commit comments

Comments
 (0)