@@ -573,7 +573,7 @@ PySSL_ChainExceptions(PySSLSocket *sslsock) {
573
573
}
574
574
575
575
static PyObject *
576
- PySSL_SetError (PySSLSocket * sslsock , int ret , const char * filename , int lineno )
576
+ PySSL_SetError (PySSLSocket * sslsock , const char * filename , int lineno )
577
577
{
578
578
PyObject * type ;
579
579
char * errstr = NULL ;
@@ -586,7 +586,6 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
586
586
_sslmodulestate * state = get_state_sock (sslsock );
587
587
type = state -> PySSLErrorObject ;
588
588
589
- assert (ret <= 0 );
590
589
e = ERR_peek_last_error ();
591
590
592
591
if (sslsock -> ssl != NULL ) {
@@ -619,32 +618,21 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
619
618
case SSL_ERROR_SYSCALL :
620
619
{
621
620
if (e == 0 ) {
622
- PySocketSockObject * s = GET_SOCKET (sslsock );
623
- if (ret == 0 || (((PyObject * )s ) == Py_None )) {
621
+ /* underlying BIO reported an I/O error */
622
+ ERR_clear_error ();
623
+ #ifdef MS_WINDOWS
624
+ if (err .ws ) {
625
+ return PyErr_SetFromWindowsErr (err .ws );
626
+ }
627
+ #endif
628
+ if (err .c ) {
629
+ errno = err .c ;
630
+ return PyErr_SetFromErrno (PyExc_OSError );
631
+ }
632
+ else {
624
633
p = PY_SSL_ERROR_EOF ;
625
634
type = state -> PySSLEOFErrorObject ;
626
635
errstr = "EOF occurred in violation of protocol" ;
627
- } else if (s && ret == -1 ) {
628
- /* underlying BIO reported an I/O error */
629
- ERR_clear_error ();
630
- #ifdef MS_WINDOWS
631
- if (err .ws ) {
632
- return PyErr_SetFromWindowsErr (err .ws );
633
- }
634
- #endif
635
- if (err .c ) {
636
- errno = err .c ;
637
- return PyErr_SetFromErrno (PyExc_OSError );
638
- }
639
- else {
640
- p = PY_SSL_ERROR_EOF ;
641
- type = state -> PySSLEOFErrorObject ;
642
- errstr = "EOF occurred in violation of protocol" ;
643
- }
644
- } else { /* possible? */
645
- p = PY_SSL_ERROR_SYSCALL ;
646
- type = state -> PySSLSyscallErrorObject ;
647
- errstr = "Some I/O error occurred" ;
648
636
}
649
637
} else {
650
638
if (ERR_GET_LIB (e ) == ERR_LIB_SSL &&
@@ -1007,7 +995,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self)
1007
995
err .ssl == SSL_ERROR_WANT_WRITE );
1008
996
Py_XDECREF (sock );
1009
997
if (ret < 1 )
1010
- return PySSL_SetError (self , ret , __FILE__ , __LINE__ );
998
+ return PySSL_SetError (self , __FILE__ , __LINE__ );
1011
999
if (PySSL_ChainExceptions (self ) < 0 )
1012
1000
return NULL ;
1013
1001
Py_RETURN_NONE ;
@@ -2424,7 +2412,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
2424
2412
2425
2413
Py_XDECREF (sock );
2426
2414
if (retval == 0 )
2427
- return PySSL_SetError (self , retval , __FILE__ , __LINE__ );
2415
+ return PySSL_SetError (self , __FILE__ , __LINE__ );
2428
2416
if (PySSL_ChainExceptions (self ) < 0 )
2429
2417
return NULL ;
2430
2418
return PyLong_FromSize_t (count );
@@ -2454,7 +2442,7 @@ _ssl__SSLSocket_pending_impl(PySSLSocket *self)
2454
2442
self -> err = err ;
2455
2443
2456
2444
if (count < 0 )
2457
- return PySSL_SetError (self , count , __FILE__ , __LINE__ );
2445
+ return PySSL_SetError (self , __FILE__ , __LINE__ );
2458
2446
else
2459
2447
return PyLong_FromLong (count );
2460
2448
}
@@ -2577,7 +2565,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
2577
2565
err .ssl == SSL_ERROR_WANT_WRITE );
2578
2566
2579
2567
if (retval == 0 ) {
2580
- PySSL_SetError (self , retval , __FILE__ , __LINE__ );
2568
+ PySSL_SetError (self , __FILE__ , __LINE__ );
2581
2569
goto error ;
2582
2570
}
2583
2571
if (self -> exc != NULL )
@@ -2703,7 +2691,7 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
2703
2691
}
2704
2692
if (ret < 0 ) {
2705
2693
Py_XDECREF (sock );
2706
- PySSL_SetError (self , ret , __FILE__ , __LINE__ );
2694
+ PySSL_SetError (self , __FILE__ , __LINE__ );
2707
2695
return NULL ;
2708
2696
}
2709
2697
if (self -> exc != NULL )
0 commit comments