@@ -2579,8 +2579,8 @@ sock_close(PySocketSockObject *s)
25792579 int res ;
25802580
25812581 fd = s -> sock_fd ;
2582- if (fd != -1 ) {
2583- s -> sock_fd = -1 ;
2582+ if (fd != INVALID_SOCKET ) {
2583+ s -> sock_fd = INVALID_SOCKET ;
25842584
25852585 /* We do not want to retry upon EINTR: see
25862586 http://lwn.net/Articles/576478/ and
@@ -2606,7 +2606,7 @@ static PyObject *
26062606sock_detach (PySocketSockObject * s )
26072607{
26082608 SOCKET_T fd = s -> sock_fd ;
2609- s -> sock_fd = -1 ;
2609+ s -> sock_fd = INVALID_SOCKET ;
26102610 return PyLong_FromSocket_t (fd );
26112611}
26122612
@@ -4202,7 +4202,7 @@ sock_finalize(PySocketSockObject *s)
42024202 /* Save the current exception, if any. */
42034203 PyErr_Fetch (& error_type , & error_value , & error_traceback );
42044204
4205- if (s -> sock_fd != -1 ) {
4205+ if (s -> sock_fd != INVALID_SOCKET ) {
42064206 if (PyErr_ResourceWarning ((PyObject * )s , 1 , "unclosed %R" , s )) {
42074207 /* Spurious errors can appear at shutdown */
42084208 if (PyErr_ExceptionMatches (PyExc_Warning )) {
@@ -4215,7 +4215,7 @@ sock_finalize(PySocketSockObject *s)
42154215 socket.getsockname(). If the socket is closed before, socket
42164216 methods fails with the EBADF error. */
42174217 fd = s -> sock_fd ;
4218- s -> sock_fd = -1 ;
4218+ s -> sock_fd = INVALID_SOCKET ;
42194219
42204220 /* We do not want to retry upon EINTR: see sock_close() */
42214221 Py_BEGIN_ALLOW_THREADS
@@ -4275,7 +4275,7 @@ sock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
42754275
42764276 new = type -> tp_alloc (type , 0 );
42774277 if (new != NULL ) {
4278- ((PySocketSockObject * )new )-> sock_fd = -1 ;
4278+ ((PySocketSockObject * )new )-> sock_fd = INVALID_SOCKET ;
42794279 ((PySocketSockObject * )new )-> sock_timeout = _PyTime_FromSeconds (-1 );
42804280 ((PySocketSockObject * )new )-> errorhandler = & set_error ;
42814281 }
0 commit comments