From d55340253979ceaa997c3ba2643f610d6ce295f7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 4 Jul 2017 13:31:04 +0200 Subject: [PATCH] bpo-30319: socket.close() now ignores ECONNRESET socket.close() was modified in Python 3.6 to raise OSError on failure: see bpo-26685. --- .../next/Library/2017-07-04-13-48-21.bpo-30319.hg_3TX.rst | 1 + Modules/socketmodule.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2017-07-04-13-48-21.bpo-30319.hg_3TX.rst diff --git a/Misc/NEWS.d/next/Library/2017-07-04-13-48-21.bpo-30319.hg_3TX.rst b/Misc/NEWS.d/next/Library/2017-07-04-13-48-21.bpo-30319.hg_3TX.rst new file mode 100644 index 00000000000000..1112d2f373753c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-07-04-13-48-21.bpo-30319.hg_3TX.rst @@ -0,0 +1 @@ +socket.close() now ignores ECONNRESET error. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index a1d829f9cb09a7..e18dd32d90045d 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2696,7 +2696,9 @@ sock_close(PySocketSockObject *s) Py_BEGIN_ALLOW_THREADS res = SOCKETCLOSE(fd); Py_END_ALLOW_THREADS - if (res < 0) { + /* bpo-30319: The peer can already have closed the connection. + Python ignores ECONNRESET on close(). */ + if (res < 0 && errno != ECONNRESET) { return s->errorhandler(); } }