Skip to content

Commit 67e1478

Browse files
authored
bpo-30319: socket.close() now ignores ECONNRESET (#2565)
socket.close() was modified in Python 3.6 to raise OSError on failure: see bpo-26685.
1 parent 378ebb6 commit 67e1478

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
socket.close() now ignores ECONNRESET error.

Modules/socketmodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,9 @@ sock_close(PySocketSockObject *s)
26962696
Py_BEGIN_ALLOW_THREADS
26972697
res = SOCKETCLOSE(fd);
26982698
Py_END_ALLOW_THREADS
2699-
if (res < 0) {
2699+
/* bpo-30319: The peer can already have closed the connection.
2700+
Python ignores ECONNRESET on close(). */
2701+
if (res < 0 && errno != ECONNRESET) {
27002702
return s->errorhandler();
27012703
}
27022704
}

0 commit comments

Comments
 (0)