@@ -582,7 +582,7 @@ PySSL_ChainExceptions(PySSLSocket *sslsock) {
582
582
}
583
583
584
584
static PyObject *
585
- PySSL_SetError (PySSLSocket * sslsock , int ret , const char * filename , int lineno )
585
+ PySSL_SetError (PySSLSocket * sslsock , const char * filename , int lineno )
586
586
{
587
587
PyObject * type ;
588
588
char * errstr = NULL ;
@@ -595,7 +595,6 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
595
595
_sslmodulestate * state = get_state_sock (sslsock );
596
596
type = state -> PySSLErrorObject ;
597
597
598
- assert (ret <= 0 );
599
598
e = ERR_peek_last_error ();
600
599
601
600
if (sslsock -> ssl != NULL ) {
@@ -628,32 +627,21 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
628
627
case SSL_ERROR_SYSCALL :
629
628
{
630
629
if (e == 0 ) {
631
- PySocketSockObject * s = GET_SOCKET (sslsock );
632
- if (ret == 0 || (((PyObject * )s ) == Py_None )) {
630
+ /* underlying BIO reported an I/O error */
631
+ ERR_clear_error ();
632
+ #ifdef MS_WINDOWS
633
+ if (err .ws ) {
634
+ return PyErr_SetFromWindowsErr (err .ws );
635
+ }
636
+ #endif
637
+ if (err .c ) {
638
+ errno = err .c ;
639
+ return PyErr_SetFromErrno (PyExc_OSError );
640
+ }
641
+ else {
633
642
p = PY_SSL_ERROR_EOF ;
634
643
type = state -> PySSLEOFErrorObject ;
635
644
errstr = "EOF occurred in violation of protocol" ;
636
- } else if (s && ret == -1 ) {
637
- /* underlying BIO reported an I/O error */
638
- ERR_clear_error ();
639
- #ifdef MS_WINDOWS
640
- if (err .ws ) {
641
- return PyErr_SetFromWindowsErr (err .ws );
642
- }
643
- #endif
644
- if (err .c ) {
645
- errno = err .c ;
646
- return PyErr_SetFromErrno (PyExc_OSError );
647
- }
648
- else {
649
- p = PY_SSL_ERROR_EOF ;
650
- type = state -> PySSLEOFErrorObject ;
651
- errstr = "EOF occurred in violation of protocol" ;
652
- }
653
- } else { /* possible? */
654
- p = PY_SSL_ERROR_SYSCALL ;
655
- type = state -> PySSLSyscallErrorObject ;
656
- errstr = "Some I/O error occurred" ;
657
645
}
658
646
} else {
659
647
if (ERR_GET_LIB (e ) == ERR_LIB_SYS ) {
@@ -1014,7 +1002,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self)
1014
1002
err .ssl == SSL_ERROR_WANT_WRITE );
1015
1003
Py_XDECREF (sock );
1016
1004
if (ret < 1 )
1017
- return PySSL_SetError (self , ret , __FILE__ , __LINE__ );
1005
+ return PySSL_SetError (self , __FILE__ , __LINE__ );
1018
1006
if (PySSL_ChainExceptions (self ) < 0 )
1019
1007
return NULL ;
1020
1008
Py_RETURN_NONE ;
@@ -2433,7 +2421,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
2433
2421
2434
2422
Py_XDECREF (sock );
2435
2423
if (retval == 0 )
2436
- return PySSL_SetError (self , retval , __FILE__ , __LINE__ );
2424
+ return PySSL_SetError (self , __FILE__ , __LINE__ );
2437
2425
if (PySSL_ChainExceptions (self ) < 0 )
2438
2426
return NULL ;
2439
2427
return PyLong_FromSize_t (count );
@@ -2463,7 +2451,7 @@ _ssl__SSLSocket_pending_impl(PySSLSocket *self)
2463
2451
self -> err = err ;
2464
2452
2465
2453
if (count < 0 )
2466
- return PySSL_SetError (self , count , __FILE__ , __LINE__ );
2454
+ return PySSL_SetError (self , __FILE__ , __LINE__ );
2467
2455
else
2468
2456
return PyLong_FromLong (count );
2469
2457
}
@@ -2585,7 +2573,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
2585
2573
err .ssl == SSL_ERROR_WANT_WRITE );
2586
2574
2587
2575
if (retval == 0 ) {
2588
- PySSL_SetError (self , retval , __FILE__ , __LINE__ );
2576
+ PySSL_SetError (self , __FILE__ , __LINE__ );
2589
2577
goto error ;
2590
2578
}
2591
2579
if (self -> exc_type != NULL )
@@ -2709,7 +2697,7 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
2709
2697
}
2710
2698
if (ret < 0 ) {
2711
2699
Py_XDECREF (sock );
2712
- PySSL_SetError (self , ret , __FILE__ , __LINE__ );
2700
+ PySSL_SetError (self , __FILE__ , __LINE__ );
2713
2701
return NULL ;
2714
2702
}
2715
2703
if (self -> exc_type != NULL )
0 commit comments