Skip to content

Commit 4fc368d

Browse files
committed
fix error/fallback (implement changes)
1 parent ae5ac4b commit 4fc368d

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

Modules/_threadmodule.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,25 +2649,17 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj)
26492649
#endif
26502650

26512651
int rc = set_encoded_thread_name(name_obj, encoding);
2652-
if (rc == -1) {
2653-
/* Confirm a Python exception was set by the helper.
2654-
If not, convert to a runtime error (defensive). */
2655-
if (PyErr_Occurred()) {
2656-
return NULL;
2657-
}
2658-
PyErr_SetString(PyExc_RuntimeError, "internal error in set_encoded_thread_name");
2652+
/* Confirm a Python exception was set by the helper.
2653+
If not, convert to a runtime error (defensive). */
2654+
if (rc == -1 && PyErr_Occurred()) {
26592655
return NULL;
26602656
}
26612657

26622658
if (rc) {
26632659
/* If native API refused (EINVAL) and we didn't try ASCII, retry with ASCII. */
26642660
if (rc == EINVAL && strcmp(encoding, "ascii") != 0) {
26652661
rc = set_encoded_thread_name(name_obj, "ascii");
2666-
if (rc == -1) {
2667-
if (PyErr_Occurred()) {
2668-
return NULL;
2669-
}
2670-
PyErr_SetString(PyExc_RuntimeError, "internal error in set_encoded_thread_name");
2662+
if (rc == -1 && PyErr_Occurred()) {
26712663
return NULL;
26722664
}
26732665
if (rc == 0) {

0 commit comments

Comments
 (0)