File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments