Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 31797:846b3ee7e106 legacy-trunk
Changed random calls to PyThreadState_Get() to use the macro
| author | Nicholas Bastin <nick.bastin@gmail.com> |
|---|---|
| date | Wed, 24 Mar 2004 22:22:12 +0000 |
| parents | 1c117dbb2def |
| children | 41c59d80bbc5 |
comparison
equal
deleted
inserted
replaced
| 31796:1c117dbb2def | 31797:846b3ee7e106 |
|---|---|
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 PyObject * | 48 PyObject * |
| 49 PySys_GetObject(char *name) | 49 PySys_GetObject(char *name) |
| 50 { | 50 { |
| 51 PyThreadState *tstate = PyThreadState_Get(); | 51 PyThreadState *tstate = PyThreadState_GET(); |
| 52 PyObject *sd = tstate->interp->sysdict; | 52 PyObject *sd = tstate->interp->sysdict; |
| 53 if (sd == NULL) | 53 if (sd == NULL) |
| 54 return NULL; | 54 return NULL; |
| 55 return PyDict_GetItemString(sd, name); | 55 return PyDict_GetItemString(sd, name); |
| 56 } | 56 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 int | 70 int |
| 71 PySys_SetObject(char *name, PyObject *v) | 71 PySys_SetObject(char *name, PyObject *v) |
| 72 { | 72 { |
| 73 PyThreadState *tstate = PyThreadState_Get(); | 73 PyThreadState *tstate = PyThreadState_GET(); |
| 74 PyObject *sd = tstate->interp->sysdict; | 74 PyObject *sd = tstate->interp->sysdict; |
| 75 if (v == NULL) { | 75 if (v == NULL) { |
| 76 if (PyDict_GetItemString(sd, name) == NULL) | 76 if (PyDict_GetItemString(sd, name) == NULL) |
| 77 return 0; | 77 return 0; |
| 78 else | 78 else |
| 84 | 84 |
| 85 static PyObject * | 85 static PyObject * |
| 86 sys_displayhook(PyObject *self, PyObject *o) | 86 sys_displayhook(PyObject *self, PyObject *o) |
| 87 { | 87 { |
| 88 PyObject *outf; | 88 PyObject *outf; |
| 89 PyInterpreterState *interp = PyThreadState_Get()->interp; | 89 PyInterpreterState *interp = PyThreadState_GET()->interp; |
| 90 PyObject *modules = interp->modules; | 90 PyObject *modules = interp->modules; |
| 91 PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); | 91 PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); |
| 92 | 92 |
| 93 if (builtins == NULL) { | 93 if (builtins == NULL) { |
| 94 PyErr_SetString(PyExc_RuntimeError, "lost __builtin__"); | 94 PyErr_SetString(PyExc_RuntimeError, "lost __builtin__"); |
| 147 | 147 |
| 148 static PyObject * | 148 static PyObject * |
| 149 sys_exc_info(PyObject *self, PyObject *noargs) | 149 sys_exc_info(PyObject *self, PyObject *noargs) |
| 150 { | 150 { |
| 151 PyThreadState *tstate; | 151 PyThreadState *tstate; |
| 152 tstate = PyThreadState_Get(); | 152 tstate = PyThreadState_GET(); |
| 153 return Py_BuildValue( | 153 return Py_BuildValue( |
| 154 "(OOO)", | 154 "(OOO)", |
| 155 tstate->exc_type != NULL ? tstate->exc_type : Py_None, | 155 tstate->exc_type != NULL ? tstate->exc_type : Py_None, |
| 156 tstate->exc_value != NULL ? tstate->exc_value : Py_None, | 156 tstate->exc_value != NULL ? tstate->exc_value : Py_None, |
| 157 tstate->exc_traceback != NULL ? | 157 tstate->exc_traceback != NULL ? |
| 166 ); | 166 ); |
| 167 | 167 |
| 168 static PyObject * | 168 static PyObject * |
| 169 sys_exc_clear(PyObject *self, PyObject *noargs) | 169 sys_exc_clear(PyObject *self, PyObject *noargs) |
| 170 { | 170 { |
| 171 PyThreadState *tstate = PyThreadState_Get(); | 171 PyThreadState *tstate = PyThreadState_GET(); |
| 172 PyObject *tmp_type, *tmp_value, *tmp_tb; | 172 PyObject *tmp_type, *tmp_value, *tmp_tb; |
| 173 tmp_type = tstate->exc_type; | 173 tmp_type = tstate->exc_type; |
| 174 tmp_value = tstate->exc_value; | 174 tmp_value = tstate->exc_value; |
| 175 tmp_tb = tstate->exc_traceback; | 175 tmp_tb = tstate->exc_traceback; |
| 176 tstate->exc_type = NULL; | 176 tstate->exc_type = NULL; |
| 512 #ifdef HAVE_DLOPEN | 512 #ifdef HAVE_DLOPEN |
| 513 static PyObject * | 513 static PyObject * |
| 514 sys_setdlopenflags(PyObject *self, PyObject *args) | 514 sys_setdlopenflags(PyObject *self, PyObject *args) |
| 515 { | 515 { |
| 516 int new_val; | 516 int new_val; |
| 517 PyThreadState *tstate = PyThreadState_Get(); | 517 PyThreadState *tstate = PyThreadState_GET(); |
| 518 if (!PyArg_ParseTuple(args, "i:setdlopenflags", &new_val)) | 518 if (!PyArg_ParseTuple(args, "i:setdlopenflags", &new_val)) |
| 519 return NULL; | 519 return NULL; |
| 520 if (!tstate) | 520 if (!tstate) |
| 521 return NULL; | 521 return NULL; |
| 522 tstate->interp->dlopenflags = new_val; | 522 tstate->interp->dlopenflags = new_val; |
| 535 ); | 535 ); |
| 536 | 536 |
| 537 static PyObject * | 537 static PyObject * |
| 538 sys_getdlopenflags(PyObject *self, PyObject *args) | 538 sys_getdlopenflags(PyObject *self, PyObject *args) |
| 539 { | 539 { |
| 540 PyThreadState *tstate = PyThreadState_Get(); | 540 PyThreadState *tstate = PyThreadState_GET(); |
| 541 if (!tstate) | 541 if (!tstate) |
| 542 return NULL; | 542 return NULL; |
| 543 return PyInt_FromLong(tstate->interp->dlopenflags); | 543 return PyInt_FromLong(tstate->interp->dlopenflags); |
| 544 } | 544 } |
| 545 | 545 |
| 613 ); | 613 ); |
| 614 | 614 |
| 615 static PyObject * | 615 static PyObject * |
| 616 sys_getframe(PyObject *self, PyObject *args) | 616 sys_getframe(PyObject *self, PyObject *args) |
| 617 { | 617 { |
| 618 PyFrameObject *f = PyThreadState_Get()->frame; | 618 PyFrameObject *f = PyThreadState_GET()->frame; |
| 619 int depth = -1; | 619 int depth = -1; |
| 620 | 620 |
| 621 if (!PyArg_ParseTuple(args, "|i:_getframe", &depth)) | 621 if (!PyArg_ParseTuple(args, "|i:_getframe", &depth)) |
| 622 return NULL; | 622 return NULL; |
| 623 | 623 |
