Skip to content

Commit e5662ae

Browse files
committed
Changed random calls to PyThreadState_Get() to use the macro
1 parent c69ebe8 commit e5662ae

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

Modules/threadmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
233233
boot = PyMem_NEW(struct bootstate, 1);
234234
if (boot == NULL)
235235
return PyErr_NoMemory();
236-
boot->interp = PyThreadState_Get()->interp;
236+
boot->interp = PyThreadState_GET()->interp;
237237
boot->func = func;
238238
boot->args = args;
239239
boot->keyw = keyw;

Python/ceval.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,7 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
28432843
{
28442844
if (type == NULL) {
28452845
/* Reraise */
2846-
PyThreadState *tstate = PyThreadState_Get();
2846+
PyThreadState *tstate = PyThreadState_GET();
28472847
type = tstate->exc_type == NULL ? Py_None : tstate->exc_type;
28482848
value = tstate->exc_value;
28492849
tb = tstate->exc_traceback;
@@ -3221,7 +3221,7 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj,
32213221
void
32223222
PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
32233223
{
3224-
PyThreadState *tstate = PyThreadState_Get();
3224+
PyThreadState *tstate = PyThreadState_GET();
32253225
PyObject *temp = tstate->c_profileobj;
32263226
Py_XINCREF(arg);
32273227
tstate->c_profilefunc = NULL;
@@ -3236,7 +3236,7 @@ PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
32363236
void
32373237
PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
32383238
{
3239-
PyThreadState *tstate = PyThreadState_Get();
3239+
PyThreadState *tstate = PyThreadState_GET();
32403240
PyObject *temp = tstate->c_traceobj;
32413241
Py_XINCREF(arg);
32423242
tstate->c_tracefunc = NULL;
@@ -3254,7 +3254,7 @@ PyEval_GetBuiltins(void)
32543254
{
32553255
PyFrameObject *current_frame = PyEval_GetFrame();
32563256
if (current_frame == NULL)
3257-
return PyThreadState_Get()->interp->builtins;
3257+
return PyThreadState_GET()->interp->builtins;
32583258
else
32593259
return current_frame->f_builtins;
32603260
}
@@ -3282,7 +3282,7 @@ PyEval_GetGlobals(void)
32823282
PyFrameObject *
32833283
PyEval_GetFrame(void)
32843284
{
3285-
PyThreadState *tstate = PyThreadState_Get();
3285+
PyThreadState *tstate = PyThreadState_GET();
32863286
return _PyThreadState_GetFrame(tstate);
32873287
}
32883288

Python/codecs.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static int _PyCodecRegistry_Init(void); /* Forward */
2828

2929
int PyCodec_Register(PyObject *search_function)
3030
{
31-
PyInterpreterState *interp = PyThreadState_Get()->interp;
31+
PyInterpreterState *interp = PyThreadState_GET()->interp;
3232
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
3333
goto onError;
3434
if (search_function == NULL) {
@@ -103,7 +103,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
103103
goto onError;
104104
}
105105

106-
interp = PyThreadState_Get()->interp;
106+
interp = PyThreadState_GET()->interp;
107107
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
108108
goto onError;
109109

@@ -395,7 +395,7 @@ PyObject *PyCodec_Decode(PyObject *object,
395395
Return 0 on success, -1 on error */
396396
int PyCodec_RegisterError(const char *name, PyObject *error)
397397
{
398-
PyInterpreterState *interp = PyThreadState_Get()->interp;
398+
PyInterpreterState *interp = PyThreadState_GET()->interp;
399399
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
400400
return -1;
401401
if (!PyCallable_Check(error)) {
@@ -413,7 +413,7 @@ PyObject *PyCodec_LookupError(const char *name)
413413
{
414414
PyObject *handler = NULL;
415415

416-
PyInterpreterState *interp = PyThreadState_Get()->interp;
416+
PyInterpreterState *interp = PyThreadState_GET()->interp;
417417
if (interp->codec_search_path == NULL && _PyCodecRegistry_Init())
418418
return NULL;
419419

@@ -802,7 +802,7 @@ static int _PyCodecRegistry_Init(void)
802802
#endif
803803
};
804804

805-
PyInterpreterState *interp = PyThreadState_Get()->interp;
805+
PyInterpreterState *interp = PyThreadState_GET()->interp;
806806
PyObject *mod;
807807
int i;
808808

Python/errors.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
205205
void
206206
PyErr_Fetch(PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
207207
{
208-
PyThreadState *tstate = PyThreadState_Get();
208+
PyThreadState *tstate = PyThreadState_GET();
209209

210210
*p_type = tstate->curexc_type;
211211
*p_value = tstate->curexc_value;

Python/import.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ imp_release_lock(PyObject *self, PyObject *noargs)
321321
PyObject *
322322
PyImport_GetModuleDict(void)
323323
{
324-
PyInterpreterState *interp = PyThreadState_Get()->interp;
324+
PyInterpreterState *interp = PyThreadState_GET()->interp;
325325
if (interp->modules == NULL)
326326
Py_FatalError("PyImport_GetModuleDict: no module dictionary!");
327327
return interp->modules;
@@ -353,7 +353,7 @@ PyImport_Cleanup(void)
353353
int pos, ndone;
354354
char *name;
355355
PyObject *key, *value, *dict;
356-
PyInterpreterState *interp = PyThreadState_Get()->interp;
356+
PyInterpreterState *interp = PyThreadState_GET()->interp;
357357
PyObject *modules = interp->modules;
358358

359359
if (modules == NULL)

Python/pystate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ PyThreadState_GetDict(void)
313313

314314
int
315315
PyThreadState_SetAsyncExc(long id, PyObject *exc) {
316-
PyThreadState *tstate = PyThreadState_Get();
316+
PyThreadState *tstate = PyThreadState_GET();
317317
PyInterpreterState *interp = tstate->interp;
318318
PyThreadState *p;
319319
int count = 0;

Python/pythonrun.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Py_Finalize(void)
316316
initialized = 0;
317317

318318
/* Get current thread state and interpreter pointer */
319-
tstate = PyThreadState_Get();
319+
tstate = PyThreadState_GET();
320320
interp = tstate->interp;
321321

322322
/* Disable signal handling */
@@ -529,7 +529,7 @@ Py_EndInterpreter(PyThreadState *tstate)
529529
{
530530
PyInterpreterState *interp = tstate->interp;
531531

532-
if (tstate != PyThreadState_Get())
532+
if (tstate != PyThreadState_GET())
533533
Py_FatalError("Py_EndInterpreter: thread is not current");
534534
if (tstate->frame != NULL)
535535
Py_FatalError("Py_EndInterpreter: thread still has a frame");
@@ -1461,7 +1461,7 @@ err_input(perrdetail *err)
14611461
msg = "too many levels of indentation";
14621462
break;
14631463
case E_DECODE: { /* XXX */
1464-
PyThreadState* tstate = PyThreadState_Get();
1464+
PyThreadState* tstate = PyThreadState_GET();
14651465
PyObject* value = tstate->curexc_value;
14661466
if (value != NULL) {
14671467
u = PyObject_Repr(value);

Python/sysmodule.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern const char *PyWin_DLLVersionString;
4848
PyObject *
4949
PySys_GetObject(char *name)
5050
{
51-
PyThreadState *tstate = PyThreadState_Get();
51+
PyThreadState *tstate = PyThreadState_GET();
5252
PyObject *sd = tstate->interp->sysdict;
5353
if (sd == NULL)
5454
return NULL;
@@ -70,7 +70,7 @@ PySys_GetFile(char *name, FILE *def)
7070
int
7171
PySys_SetObject(char *name, PyObject *v)
7272
{
73-
PyThreadState *tstate = PyThreadState_Get();
73+
PyThreadState *tstate = PyThreadState_GET();
7474
PyObject *sd = tstate->interp->sysdict;
7575
if (v == NULL) {
7676
if (PyDict_GetItemString(sd, name) == NULL)
@@ -86,7 +86,7 @@ static PyObject *
8686
sys_displayhook(PyObject *self, PyObject *o)
8787
{
8888
PyObject *outf;
89-
PyInterpreterState *interp = PyThreadState_Get()->interp;
89+
PyInterpreterState *interp = PyThreadState_GET()->interp;
9090
PyObject *modules = interp->modules;
9191
PyObject *builtins = PyDict_GetItemString(modules, "__builtin__");
9292

@@ -149,7 +149,7 @@ static PyObject *
149149
sys_exc_info(PyObject *self, PyObject *noargs)
150150
{
151151
PyThreadState *tstate;
152-
tstate = PyThreadState_Get();
152+
tstate = PyThreadState_GET();
153153
return Py_BuildValue(
154154
"(OOO)",
155155
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."
168168
static PyObject *
169169
sys_exc_clear(PyObject *self, PyObject *noargs)
170170
{
171-
PyThreadState *tstate = PyThreadState_Get();
171+
PyThreadState *tstate = PyThreadState_GET();
172172
PyObject *tmp_type, *tmp_value, *tmp_tb;
173173
tmp_type = tstate->exc_type;
174174
tmp_value = tstate->exc_value;
@@ -514,7 +514,7 @@ static PyObject *
514514
sys_setdlopenflags(PyObject *self, PyObject *args)
515515
{
516516
int new_val;
517-
PyThreadState *tstate = PyThreadState_Get();
517+
PyThreadState *tstate = PyThreadState_GET();
518518
if (!PyArg_ParseTuple(args, "i:setdlopenflags", &new_val))
519519
return NULL;
520520
if (!tstate)
@@ -537,7 +537,7 @@ sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)"
537537
static PyObject *
538538
sys_getdlopenflags(PyObject *self, PyObject *args)
539539
{
540-
PyThreadState *tstate = PyThreadState_Get();
540+
PyThreadState *tstate = PyThreadState_GET();
541541
if (!tstate)
542542
return NULL;
543543
return PyInt_FromLong(tstate->interp->dlopenflags);
@@ -615,7 +615,7 @@ purposes only."
615615
static PyObject *
616616
sys_getframe(PyObject *self, PyObject *args)
617617
{
618-
PyFrameObject *f = PyThreadState_Get()->frame;
618+
PyFrameObject *f = PyThreadState_GET()->frame;
619619
int depth = -1;
620620

621621
if (!PyArg_ParseTuple(args, "|i:_getframe", &depth))

0 commit comments

Comments
 (0)