mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-39946: Remove _PyThreadState_GetFrame (GH-19094)
Remove _PyRuntime.getframe hook and remove _PyThreadState_GetFrame macro which was an alias to _PyRuntime.getframe. They were only exposed by the internal C API. Remove also PyThreadFrameGetter type.
This commit is contained in:
parent
fd1e1a18fa
commit
6723e933c4
7 changed files with 14 additions and 34 deletions
|
@ -533,6 +533,10 @@ Build and C API Changes
|
||||||
scheduled calls.
|
scheduled calls.
|
||||||
(Contributed by Victor Stinner in :issue:`39984`.)
|
(Contributed by Victor Stinner in :issue:`39984`.)
|
||||||
|
|
||||||
|
* Remove ``_PyRuntime.getframe`` hook and remove ``_PyThreadState_GetFrame``
|
||||||
|
macro which was an alias to ``_PyRuntime.getframe``. They were only exposed
|
||||||
|
by the internal C API. Remove also ``PyThreadFrameGetter`` type.
|
||||||
|
(Contributed by Victor Stinner in :issue:`39946`.)
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
==========
|
==========
|
||||||
|
|
|
@ -179,8 +179,6 @@ PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
|
||||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
|
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
|
||||||
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
||||||
|
|
||||||
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
|
|
||||||
|
|
||||||
/* Frame evaluation API */
|
/* Frame evaluation API */
|
||||||
|
|
||||||
typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _frame *, int);
|
typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _frame *, int);
|
||||||
|
|
|
@ -192,7 +192,6 @@ struct _gilstate_runtime_state {
|
||||||
/* Assuming the current thread holds the GIL, this is the
|
/* Assuming the current thread holds the GIL, this is the
|
||||||
PyThreadState for the current thread. */
|
PyThreadState for the current thread. */
|
||||||
_Py_atomic_address tstate_current;
|
_Py_atomic_address tstate_current;
|
||||||
PyThreadFrameGetter getframe;
|
|
||||||
/* The single PyInterpreterState used by this process'
|
/* The single PyInterpreterState used by this process'
|
||||||
GILState implementation
|
GILState implementation
|
||||||
*/
|
*/
|
||||||
|
@ -201,9 +200,6 @@ struct _gilstate_runtime_state {
|
||||||
Py_tss_t autoTSSkey;
|
Py_tss_t autoTSSkey;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* hook for PyEval_GetFrame(), requested for Psyco */
|
|
||||||
#define _PyThreadState_GetFrame _PyRuntime.gilstate.getframe
|
|
||||||
|
|
||||||
/* Issue #26558: Flag to disable PyGILState_Check().
|
/* Issue #26558: Flag to disable PyGILState_Check().
|
||||||
If set to non-zero, PyGILState_Check() always return 1. */
|
If set to non-zero, PyGILState_Check() always return 1. */
|
||||||
#define _PyGILState_check_enabled _PyRuntime.gilstate.check_enabled
|
#define _PyGILState_check_enabled _PyRuntime.gilstate.check_enabled
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Remove ``_PyRuntime.getframe`` hook and remove ``_PyThreadState_GetFrame``
|
||||||
|
macro which was an alias to ``_PyRuntime.getframe``. They were only exposed
|
||||||
|
by the internal C API. Remove also ``PyThreadFrameGetter`` type.
|
|
@ -4825,25 +4825,18 @@ _PyEval_GetAsyncGenFinalizer(void)
|
||||||
return tstate->async_gen_finalizer;
|
return tstate->async_gen_finalizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyFrameObject *
|
|
||||||
_PyEval_GetFrame(PyThreadState *tstate)
|
|
||||||
{
|
|
||||||
_PyRuntimeState *runtime = tstate->interp->runtime;
|
|
||||||
return runtime->gilstate.getframe(tstate);
|
|
||||||
}
|
|
||||||
|
|
||||||
PyFrameObject *
|
PyFrameObject *
|
||||||
PyEval_GetFrame(void)
|
PyEval_GetFrame(void)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
return _PyEval_GetFrame(tstate);
|
return tstate->frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyEval_GetBuiltins(void)
|
PyEval_GetBuiltins(void)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyFrameObject *current_frame = _PyEval_GetFrame(tstate);
|
PyFrameObject *current_frame = tstate->frame;
|
||||||
if (current_frame == NULL)
|
if (current_frame == NULL)
|
||||||
return tstate->interp->builtins;
|
return tstate->interp->builtins;
|
||||||
else
|
else
|
||||||
|
@ -4869,7 +4862,7 @@ PyObject *
|
||||||
PyEval_GetLocals(void)
|
PyEval_GetLocals(void)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyFrameObject *current_frame = _PyEval_GetFrame(tstate);
|
PyFrameObject *current_frame = tstate->frame;
|
||||||
if (current_frame == NULL) {
|
if (current_frame == NULL) {
|
||||||
_PyErr_SetString(tstate, PyExc_SystemError, "frame does not exist");
|
_PyErr_SetString(tstate, PyExc_SystemError, "frame does not exist");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4887,7 +4880,7 @@ PyObject *
|
||||||
PyEval_GetGlobals(void)
|
PyEval_GetGlobals(void)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyFrameObject *current_frame = _PyEval_GetFrame(tstate);
|
PyFrameObject *current_frame = tstate->frame;
|
||||||
if (current_frame == NULL) {
|
if (current_frame == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -4900,7 +4893,7 @@ int
|
||||||
PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
|
PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyFrameObject *current_frame = _PyEval_GetFrame(tstate);
|
PyFrameObject *current_frame = tstate->frame;
|
||||||
int result = cf->cf_flags != 0;
|
int result = cf->cf_flags != 0;
|
||||||
|
|
||||||
if (current_frame != NULL) {
|
if (current_frame != NULL) {
|
||||||
|
|
|
@ -546,13 +546,6 @@ PyInterpreterState_GetDict(PyInterpreterState *interp)
|
||||||
return interp->dict;
|
return interp->dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default implementation for _PyThreadState_GetFrame */
|
|
||||||
static struct _frame *
|
|
||||||
threadstate_getframe(PyThreadState *self)
|
|
||||||
{
|
|
||||||
return self->frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyThreadState *
|
static PyThreadState *
|
||||||
new_threadstate(PyInterpreterState *interp, int init)
|
new_threadstate(PyInterpreterState *interp, int init)
|
||||||
{
|
{
|
||||||
|
@ -562,10 +555,6 @@ new_threadstate(PyInterpreterState *interp, int init)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_PyThreadState_GetFrame == NULL) {
|
|
||||||
_PyThreadState_GetFrame = threadstate_getframe;
|
|
||||||
}
|
|
||||||
|
|
||||||
tstate->interp = interp;
|
tstate->interp = interp;
|
||||||
|
|
||||||
tstate->frame = NULL;
|
tstate->frame = NULL;
|
||||||
|
@ -1000,9 +989,6 @@ PyInterpreterState *
|
||||||
PyThreadState_GetInterpreter(PyThreadState *tstate)
|
PyThreadState_GetInterpreter(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
assert(tstate != NULL);
|
assert(tstate != NULL);
|
||||||
if (tstate == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return tstate->interp;
|
return tstate->interp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,7 +997,7 @@ struct _frame*
|
||||||
PyThreadState_GetFrame(PyThreadState *tstate)
|
PyThreadState_GetFrame(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
assert(tstate != NULL);
|
assert(tstate != NULL);
|
||||||
return _PyThreadState_GetFrame(tstate);
|
return tstate->frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -801,7 +801,7 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
|
||||||
PUTS(fd, "Stack (most recent call first):\n");
|
PUTS(fd, "Stack (most recent call first):\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = _PyThreadState_GetFrame(tstate);
|
frame = tstate->frame;
|
||||||
if (frame == NULL) {
|
if (frame == NULL) {
|
||||||
PUTS(fd, "<no Python frame>\n");
|
PUTS(fd, "<no Python frame>\n");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue