mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Changed random calls to PyThreadState_Get() to use the macro
This commit is contained in:
parent
c69ebe8d50
commit
e5662aedef
8 changed files with 26 additions and 26 deletions
|
@ -233,7 +233,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
|
||||||
boot = PyMem_NEW(struct bootstate, 1);
|
boot = PyMem_NEW(struct bootstate, 1);
|
||||||
if (boot == NULL)
|
if (boot == NULL)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
boot->interp = PyThreadState_Get()->interp;
|
boot->interp = PyThreadState_GET()->interp;
|
||||||
boot->func = func;
|
boot->func = func;
|
||||||
boot->args = args;
|
boot->args = args;
|
||||||
boot->keyw = keyw;
|
boot->keyw = keyw;
|
||||||
|
|
|
@ -2843,7 +2843,7 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
|
||||||
{
|
{
|
||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
/* Reraise */
|
/* Reraise */
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
type = tstate->exc_type == NULL ? Py_None : tstate->exc_type;
|
type = tstate->exc_type == NULL ? Py_None : tstate->exc_type;
|
||||||
value = tstate->exc_value;
|
value = tstate->exc_value;
|
||||||
tb = tstate->exc_traceback;
|
tb = tstate->exc_traceback;
|
||||||
|
@ -3221,7 +3221,7 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj,
|
||||||
void
|
void
|
||||||
PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
|
PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
PyObject *temp = tstate->c_profileobj;
|
PyObject *temp = tstate->c_profileobj;
|
||||||
Py_XINCREF(arg);
|
Py_XINCREF(arg);
|
||||||
tstate->c_profilefunc = NULL;
|
tstate->c_profilefunc = NULL;
|
||||||
|
@ -3236,7 +3236,7 @@ PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
|
||||||
void
|
void
|
||||||
PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
|
PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
PyObject *temp = tstate->c_traceobj;
|
PyObject *temp = tstate->c_traceobj;
|
||||||
Py_XINCREF(arg);
|
Py_XINCREF(arg);
|
||||||
tstate->c_tracefunc = NULL;
|
tstate->c_tracefunc = NULL;
|
||||||
|
@ -3254,7 +3254,7 @@ PyEval_GetBuiltins(void)
|
||||||
{
|
{
|
||||||
PyFrameObject *current_frame = PyEval_GetFrame();
|
PyFrameObject *current_frame = PyEval_GetFrame();
|
||||||
if (current_frame == NULL)
|
if (current_frame == NULL)
|
||||||
return PyThreadState_Get()->interp->builtins;
|
return PyThreadState_GET()->interp->builtins;
|
||||||
else
|
else
|
||||||
return current_frame->f_builtins;
|
return current_frame->f_builtins;
|
||||||
}
|
}
|
||||||
|
@ -3282,7 +3282,7 @@ PyEval_GetGlobals(void)
|
||||||
PyFrameObject *
|
PyFrameObject *
|
||||||
PyEval_GetFrame(void)
|
PyEval_GetFrame(void)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
return _PyThreadState_GetFrame(tstate);
|
return _PyThreadState_GetFrame(tstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ static int _PyCodecRegistry_Init(void); /* Forward */
|
||||||
|
|
||||||
int PyCodec_Register(PyObject *search_function)
|
int PyCodec_Register(PyObject *search_function)
|
||||||
{
|
{
|
||||||
PyInterpreterState *interp = PyThreadState_Get()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
||||||
goto onError;
|
goto onError;
|
||||||
if (search_function == NULL) {
|
if (search_function == NULL) {
|
||||||
|
@ -103,7 +103,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
|
|
||||||
interp = PyThreadState_Get()->interp;
|
interp = PyThreadState_GET()->interp;
|
||||||
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
||||||
goto onError;
|
goto onError;
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ PyObject *PyCodec_Decode(PyObject *object,
|
||||||
Return 0 on success, -1 on error */
|
Return 0 on success, -1 on error */
|
||||||
int PyCodec_RegisterError(const char *name, PyObject *error)
|
int PyCodec_RegisterError(const char *name, PyObject *error)
|
||||||
{
|
{
|
||||||
PyInterpreterState *interp = PyThreadState_Get()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
||||||
return -1;
|
return -1;
|
||||||
if (!PyCallable_Check(error)) {
|
if (!PyCallable_Check(error)) {
|
||||||
|
@ -413,7 +413,7 @@ PyObject *PyCodec_LookupError(const char *name)
|
||||||
{
|
{
|
||||||
PyObject *handler = NULL;
|
PyObject *handler = NULL;
|
||||||
|
|
||||||
PyInterpreterState *interp = PyThreadState_Get()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -802,7 +802,7 @@ static int _PyCodecRegistry_Init(void)
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
PyInterpreterState *interp = PyThreadState_Get()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
PyObject *mod;
|
PyObject *mod;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ finally:
|
||||||
void
|
void
|
||||||
PyErr_Fetch(PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
|
PyErr_Fetch(PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
|
|
||||||
*p_type = tstate->curexc_type;
|
*p_type = tstate->curexc_type;
|
||||||
*p_value = tstate->curexc_value;
|
*p_value = tstate->curexc_value;
|
||||||
|
|
|
@ -321,7 +321,7 @@ imp_release_lock(PyObject *self, PyObject *noargs)
|
||||||
PyObject *
|
PyObject *
|
||||||
PyImport_GetModuleDict(void)
|
PyImport_GetModuleDict(void)
|
||||||
{
|
{
|
||||||
PyInterpreterState *interp = PyThreadState_Get()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
if (interp->modules == NULL)
|
if (interp->modules == NULL)
|
||||||
Py_FatalError("PyImport_GetModuleDict: no module dictionary!");
|
Py_FatalError("PyImport_GetModuleDict: no module dictionary!");
|
||||||
return interp->modules;
|
return interp->modules;
|
||||||
|
@ -353,7 +353,7 @@ PyImport_Cleanup(void)
|
||||||
int pos, ndone;
|
int pos, ndone;
|
||||||
char *name;
|
char *name;
|
||||||
PyObject *key, *value, *dict;
|
PyObject *key, *value, *dict;
|
||||||
PyInterpreterState *interp = PyThreadState_Get()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
PyObject *modules = interp->modules;
|
PyObject *modules = interp->modules;
|
||||||
|
|
||||||
if (modules == NULL)
|
if (modules == NULL)
|
||||||
|
|
|
@ -313,7 +313,7 @@ PyThreadState_GetDict(void)
|
||||||
|
|
||||||
int
|
int
|
||||||
PyThreadState_SetAsyncExc(long id, PyObject *exc) {
|
PyThreadState_SetAsyncExc(long id, PyObject *exc) {
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
PyInterpreterState *interp = tstate->interp;
|
PyInterpreterState *interp = tstate->interp;
|
||||||
PyThreadState *p;
|
PyThreadState *p;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
@ -316,7 +316,7 @@ Py_Finalize(void)
|
||||||
initialized = 0;
|
initialized = 0;
|
||||||
|
|
||||||
/* Get current thread state and interpreter pointer */
|
/* Get current thread state and interpreter pointer */
|
||||||
tstate = PyThreadState_Get();
|
tstate = PyThreadState_GET();
|
||||||
interp = tstate->interp;
|
interp = tstate->interp;
|
||||||
|
|
||||||
/* Disable signal handling */
|
/* Disable signal handling */
|
||||||
|
@ -529,7 +529,7 @@ Py_EndInterpreter(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
PyInterpreterState *interp = tstate->interp;
|
PyInterpreterState *interp = tstate->interp;
|
||||||
|
|
||||||
if (tstate != PyThreadState_Get())
|
if (tstate != PyThreadState_GET())
|
||||||
Py_FatalError("Py_EndInterpreter: thread is not current");
|
Py_FatalError("Py_EndInterpreter: thread is not current");
|
||||||
if (tstate->frame != NULL)
|
if (tstate->frame != NULL)
|
||||||
Py_FatalError("Py_EndInterpreter: thread still has a frame");
|
Py_FatalError("Py_EndInterpreter: thread still has a frame");
|
||||||
|
@ -1461,7 +1461,7 @@ err_input(perrdetail *err)
|
||||||
msg = "too many levels of indentation";
|
msg = "too many levels of indentation";
|
||||||
break;
|
break;
|
||||||
case E_DECODE: { /* XXX */
|
case E_DECODE: { /* XXX */
|
||||||
PyThreadState* tstate = PyThreadState_Get();
|
PyThreadState* tstate = PyThreadState_GET();
|
||||||
PyObject* value = tstate->curexc_value;
|
PyObject* value = tstate->curexc_value;
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
u = PyObject_Repr(value);
|
u = PyObject_Repr(value);
|
||||||
|
|
|
@ -48,7 +48,7 @@ extern const char *PyWin_DLLVersionString;
|
||||||
PyObject *
|
PyObject *
|
||||||
PySys_GetObject(char *name)
|
PySys_GetObject(char *name)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
PyObject *sd = tstate->interp->sysdict;
|
PyObject *sd = tstate->interp->sysdict;
|
||||||
if (sd == NULL)
|
if (sd == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -70,7 +70,7 @@ PySys_GetFile(char *name, FILE *def)
|
||||||
int
|
int
|
||||||
PySys_SetObject(char *name, PyObject *v)
|
PySys_SetObject(char *name, PyObject *v)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
PyObject *sd = tstate->interp->sysdict;
|
PyObject *sd = tstate->interp->sysdict;
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
if (PyDict_GetItemString(sd, name) == NULL)
|
if (PyDict_GetItemString(sd, name) == NULL)
|
||||||
|
@ -86,7 +86,7 @@ static PyObject *
|
||||||
sys_displayhook(PyObject *self, PyObject *o)
|
sys_displayhook(PyObject *self, PyObject *o)
|
||||||
{
|
{
|
||||||
PyObject *outf;
|
PyObject *outf;
|
||||||
PyInterpreterState *interp = PyThreadState_Get()->interp;
|
PyInterpreterState *interp = PyThreadState_GET()->interp;
|
||||||
PyObject *modules = interp->modules;
|
PyObject *modules = interp->modules;
|
||||||
PyObject *builtins = PyDict_GetItemString(modules, "__builtin__");
|
PyObject *builtins = PyDict_GetItemString(modules, "__builtin__");
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ static PyObject *
|
||||||
sys_exc_info(PyObject *self, PyObject *noargs)
|
sys_exc_info(PyObject *self, PyObject *noargs)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate;
|
PyThreadState *tstate;
|
||||||
tstate = PyThreadState_Get();
|
tstate = PyThreadState_GET();
|
||||||
return Py_BuildValue(
|
return Py_BuildValue(
|
||||||
"(OOO)",
|
"(OOO)",
|
||||||
tstate->exc_type != NULL ? tstate->exc_type : Py_None,
|
tstate->exc_type != NULL ? tstate->exc_type : Py_None,
|
||||||
|
@ -168,7 +168,7 @@ clause in the current stack frame or in an older stack frame."
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys_exc_clear(PyObject *self, PyObject *noargs)
|
sys_exc_clear(PyObject *self, PyObject *noargs)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
||||||
tmp_type = tstate->exc_type;
|
tmp_type = tstate->exc_type;
|
||||||
tmp_value = tstate->exc_value;
|
tmp_value = tstate->exc_value;
|
||||||
|
@ -514,7 +514,7 @@ static PyObject *
|
||||||
sys_setdlopenflags(PyObject *self, PyObject *args)
|
sys_setdlopenflags(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int new_val;
|
int new_val;
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
if (!PyArg_ParseTuple(args, "i:setdlopenflags", &new_val))
|
if (!PyArg_ParseTuple(args, "i:setdlopenflags", &new_val))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!tstate)
|
if (!tstate)
|
||||||
|
@ -537,7 +537,7 @@ sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)"
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys_getdlopenflags(PyObject *self, PyObject *args)
|
sys_getdlopenflags(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = PyThreadState_Get();
|
PyThreadState *tstate = PyThreadState_GET();
|
||||||
if (!tstate)
|
if (!tstate)
|
||||||
return NULL;
|
return NULL;
|
||||||
return PyInt_FromLong(tstate->interp->dlopenflags);
|
return PyInt_FromLong(tstate->interp->dlopenflags);
|
||||||
|
@ -615,7 +615,7 @@ purposes only."
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys_getframe(PyObject *self, PyObject *args)
|
sys_getframe(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyFrameObject *f = PyThreadState_Get()->frame;
|
PyFrameObject *f = PyThreadState_GET()->frame;
|
||||||
int depth = -1;
|
int depth = -1;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|i:_getframe", &depth))
|
if (!PyArg_ParseTuple(args, "|i:_getframe", &depth))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue