summaryrefslogtreecommitdiffstats
path: root/Modules/_threadmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-01 09:03:39 (GMT)
committerGitHub <noreply@github.com>2019-09-01 09:03:39 (GMT)
commit41c57b335330ff48af098d47e379e0f9ba09d233 (patch)
tree15cdef099182eddb04b2276dc51375b8faf28278 /Modules/_threadmodule.c
parentf02ea6225bc3b71bd5fe66224d199a6e3e23b14d (diff)
downloadcpython-41c57b335330ff48af098d47e379e0f9ba09d233.zip
cpython-41c57b335330ff48af098d47e379e0f9ba09d233.tar.gz
cpython-41c57b335330ff48af098d47e379e0f9ba09d233.tar.bz2
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r--Modules/_threadmodule.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 6665827..a3ecd2e 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -1313,6 +1313,7 @@ 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;
@@ -1320,7 +1321,9 @@ thread_excepthook_file(PyObject *file, PyObject *exc_type, PyObject *exc_value,
PyObject *name = NULL;
if (thread != Py_None) {
- name = PyObject_GetAttrString(thread, "name");
+ if (_PyObject_LookupAttrId(thread, &PyId_name, &name) < 0) {
+ return -1;
+ }
}
if (name != NULL) {
if (PyFile_WriteObject(name, file, Py_PRINT_RAW) < 0) {
@@ -1330,8 +1333,6 @@ thread_excepthook_file(PyObject *file, PyObject *exc_type, PyObject *exc_value,
Py_DECREF(name);
}
else {
- PyErr_Clear();
-
unsigned long ident = PyThread_get_thread_ident();
PyObject *str = PyUnicode_FromFormat("%lu", ident);
if (str != NULL) {