diff options
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r-- | Modules/_threadmodule.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 7052d4c..072b79a 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -17,11 +17,6 @@ // ThreadError is just an alias to PyExc_RuntimeError #define ThreadError PyExc_RuntimeError -_Py_IDENTIFIER(__dict__); - -_Py_IDENTIFIER(stderr); -_Py_IDENTIFIER(flush); - // Forward declarations static struct PyModuleDef thread_module; @@ -938,12 +933,7 @@ local_setattro(localobject *self, PyObject *name, PyObject *v) return -1; } - PyObject *str_dict = _PyUnicode_FromId(&PyId___dict__); // borrowed ref - if (str_dict == NULL) { - return -1; - } - - int r = PyObject_RichCompareBool(name, str_dict, Py_EQ); + int r = PyObject_RichCompareBool(name, &_Py_ID(__dict__), Py_EQ); if (r == -1) { return -1; } @@ -994,12 +984,7 @@ local_getattro(localobject *self, PyObject *name) if (ldict == NULL) return NULL; - PyObject *str_dict = _PyUnicode_FromId(&PyId___dict__); // borrowed ref - if (str_dict == NULL) { - return NULL; - } - - int r = PyObject_RichCompareBool(name, str_dict, Py_EQ); + int r = PyObject_RichCompareBool(name, &_Py_ID(__dict__), Py_EQ); if (r == 1) { return Py_NewRef(ldict); } @@ -1413,7 +1398,6 @@ static int thread_excepthook_file(PyObject *file, PyObject *exc_type, PyObject *exc_value, PyObject *exc_traceback, PyObject *thread) { - _Py_IDENTIFIER(name); /* print(f"Exception in thread {thread.name}:", file=file) */ if (PyFile_WriteString("Exception in thread ", file) < 0) { return -1; @@ -1421,7 +1405,7 @@ thread_excepthook_file(PyObject *file, PyObject *exc_type, PyObject *exc_value, PyObject *name = NULL; if (thread != Py_None) { - if (_PyObject_LookupAttrId(thread, &PyId_name, &name) < 0) { + if (_PyObject_LookupAttr(thread, &_Py_ID(name), &name) < 0) { return -1; } } @@ -1459,7 +1443,7 @@ thread_excepthook_file(PyObject *file, PyObject *exc_type, PyObject *exc_value, _PyErr_Display(file, exc_type, exc_value, exc_traceback); /* Call file.flush() */ - PyObject *res = _PyObject_CallMethodIdNoArgs(file, &PyId_flush); + PyObject *res = PyObject_CallMethodNoArgs(file, &_Py_ID(flush)); if (!res) { return -1; } @@ -1514,7 +1498,8 @@ thread_excepthook(PyObject *module, PyObject *args) PyObject *exc_tb = PyStructSequence_GET_ITEM(args, 2); PyObject *thread = PyStructSequence_GET_ITEM(args, 3); - PyObject *file = _PySys_GetObjectId(&PyId_stderr); + PyThreadState *tstate = _PyThreadState_GET(); + PyObject *file = _PySys_GetAttr(tstate, &_Py_ID(stderr)); if (file == NULL || file == Py_None) { if (thread == Py_None) { /* do nothing if sys.stderr is None and thread is None */ |