mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
This commit is contained in:
parent
f02ea6225b
commit
41c57b3353
14 changed files with 134 additions and 127 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue