Skip to content

Commit 580cd5c

Browse files
authored
bpo-30319: socket.close() now ignores ECONNRESET (#2565) (#2566)
socket.close() was modified in Python 3.6 to raise OSError on failure: see bpo-26685. (cherry picked from commit 67e1478)
1 parent 23e2c3d commit 580cd5c

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
@@ -2704,7 +2704,9 @@ sock_close(PySocketSockObject *s)
27042704
Py_BEGIN_ALLOW_THREADS
27052705
res = SOCKETCLOSE(fd);
27062706
Py_END_ALLOW_THREADS
2707-
if (res < 0) {
2707+
/* bpo-30319: The peer can already have closed the connection.
2708+
Python ignores ECONNRESET on close(). */
2709+
if (res < 0 && errno != ECONNRESET) {
27082710
return s->errorhandler();
27092711
}
27102712
}

0 commit comments

Comments
 (0)