Blame SOURCES/00318-test-ssl-fix-for-tls-13.patch

b9ffd2
bpo-32947: test_ssl fixes for TLS 1.3 and OpenSSL 1.1.1
b9ffd2
b9ffd2
Backport partially commit 529525fb5a8fd9b96ab4021311a598c77588b918:
b9ffd2
complete the previous partial backport (commit
b9ffd2
2a4ee8aa01d61b6a9c8e9c65c211e61bdb471826.
b9ffd2
b9ffd2
Reported upstream:
b9ffd2
b9ffd2
* https://bugs.python.org/issue32947#msg333990
b9ffd2
* https://github.com/python/cpython/pull/11612
b9ffd2
c13b57
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
b9ffd2
index 7f8f636..05c09a6 100644
c13b57
--- a/Lib/test/test_ssl.py
c13b57
+++ b/Lib/test/test_ssl.py
c13b57
@@ -2021,6 +2021,16 @@ if _have_threads:
c13b57
                                 sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n"
c13b57
                                                  % (msg, ctype, msg.lower(), ctype))
c13b57
                             self.write(msg.lower())
c13b57
+                    except ConnectionResetError:
c13b57
+                        # XXX: OpenSSL 1.1.1 sometimes raises ConnectionResetError
c13b57
+                        # when connection is not shut down gracefully.
c13b57
+                        if self.server.chatty and support.verbose:
c13b57
+                            sys.stdout.write(
c13b57
+                                " Connection reset by peer: {}\n".format(
c13b57
+                                    self.addr)
c13b57
+                            )
c13b57
+                        self.close()
c13b57
+                        self.running = False
c13b57
                     except OSError:
c13b57
                         if self.server.chatty:
c13b57
                             handle_error("Test server failure:\n")
b9ffd2
@@ -2100,6 +2110,11 @@ if _have_threads:
b9ffd2
                     pass
b9ffd2
                 except KeyboardInterrupt:
b9ffd2
                     self.stop()
b9ffd2
+                except BaseException as e:
b9ffd2
+                    if support.verbose and self.chatty:
b9ffd2
+                        sys.stdout.write(
b9ffd2
+                            ' connection handling failed: ' + repr(e) + '\n')
b9ffd2
+
b9ffd2
             self.sock.close()
b9ffd2
b9ffd2
         def stop(self):