Index: Modules/_multiprocessing/multiprocessing.c =================================================================== --- Modules/_multiprocessing/multiprocessing.c (révision 64756) +++ Modules/_multiprocessing/multiprocessing.c (copie de travail) @@ -50,6 +50,10 @@ PyErr_SetString(PyExc_IOError, "got end of file during message"); break; + case MP_CLOSED_FILE: + PyErr_SetString(PyExc_IOError, + "I/O operation on closed file"); + break; case MP_BAD_MESSAGE_LENGTH: PyErr_SetString(PyExc_IOError, "bad message length"); break; Index: Modules/_multiprocessing/socket_connection.c =================================================================== --- Modules/_multiprocessing/socket_connection.c (révision 64756) +++ Modules/_multiprocessing/socket_connection.c (copie de travail) @@ -73,6 +73,9 @@ static Py_ssize_t conn_send_string(ConnectionObject *conn, char *string, size_t length) { + if (conn->handle == INVALID_HANDLE_VALUE) + return MP_CLOSED_FILE; + /* The "header" of the message is a 32 bit unsigned number (in network order) which specifies the length of the "body". If the message is shorter than about 16kb then it is quicker to @@ -116,6 +119,9 @@ int res; UINT32 ulength; + if (conn->handle == INVALID_HANDLE_VALUE) + return MP_CLOSED_FILE; + *newbuffer = NULL; res = _conn_recvall(conn->handle, (char*)&ulength, 4); @@ -148,6 +154,9 @@ int res; fd_set rfds; + if (conn->handle == INVALID_HANDLE_VALUE) + return MP_CLOSED_FILE; + FD_ZERO(&rfds); FD_SET((SOCKET)conn->handle, &rfds); Index: Modules/_multiprocessing/multiprocessing.h =================================================================== --- Modules/_multiprocessing/multiprocessing.h (révision 64756) +++ Modules/_multiprocessing/multiprocessing.h (copie de travail) @@ -97,6 +97,7 @@ #define MP_BAD_MESSAGE_LENGTH (-1004) #define MP_SOCKET_ERROR (-1005) #define MP_EXCEPTION_HAS_BEEN_SET (-1006) +#define MP_CLOSED_FILE (-1007) PyObject *mp_SetError(PyObject *Type, int num); Index: Modules/_multiprocessing/pipe_connection.c =================================================================== --- Modules/_multiprocessing/pipe_connection.c (révision 64756) +++ Modules/_multiprocessing/pipe_connection.c (copie de travail) @@ -19,6 +19,9 @@ { DWORD amount_written; + if (conn->handle == INVALID_HANDLE_VALUE) + return MP_CLOSED_FILE; + return WriteFile(conn->handle, string, length, &amount_written, NULL) ? MP_SUCCESS : MP_STANDARD_ERROR; } @@ -37,6 +40,9 @@ *newbuffer = NULL; + if (conn->handle == INVALID_HANDLE_VALUE) + return MP_CLOSED_FILE; + if (ReadFile(conn->handle, buffer, MIN(buflength, maxlength), &length, NULL)) return length; @@ -83,6 +89,9 @@ int difference, res; BOOL block = FALSE; + if (conn->handle == INVALID_HANDLE_VALUE) + return MP_CLOSED_FILE; + if (!PeekNamedPipe(conn->handle, NULL, 0, NULL, &bytes, NULL)) return MP_STANDARD_ERROR;