Skip to content

Commit 6031114

Browse files
vstinnerencukou
authored andcommitted
00457: ssl: Raise OSError for ERR_LIB_SYS
The patch resolves the flakiness of test_ftplib Backported from upstream 3.10+: python#127361 Co-authored-by: Petr Viktorin <[email protected]>
1 parent 9eb08e0 commit 6031114

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Modules/_ssl.c

+10
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,11 @@ PySSL_SetError(PySSLSocket *obj, int ret, const char *filename, int lineno)
638638
errstr = "Some I/O error occurred";
639639
}
640640
} else {
641+
if (ERR_GET_LIB(e) == ERR_LIB_SYS) {
642+
// A system error is being reported; reason is set to errno
643+
errno = ERR_GET_REASON(e);
644+
return PyErr_SetFromErrno(PyExc_OSError);
645+
}
641646
p = PY_SSL_ERROR_SYSCALL;
642647
}
643648
break;
@@ -648,6 +653,11 @@ PySSL_SetError(PySSLSocket *obj, int ret, const char *filename, int lineno)
648653
if (e == 0)
649654
/* possible? */
650655
errstr = "A failure in the SSL library occurred";
656+
if (ERR_GET_LIB(e) == ERR_LIB_SYS) {
657+
// A system error is being reported; reason is set to errno
658+
errno = ERR_GET_REASON(e);
659+
return PyErr_SetFromErrno(PyExc_OSError);
660+
}
651661
break;
652662
}
653663
default:

0 commit comments

Comments
 (0)