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

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