From d89bc052f99bf51670a87976dc6654b9f2477e07 Mon Sep 17 00:00:00 2001 From: Scott Phillips Date: Tue, 1 Feb 2022 13:06:10 -0500 Subject: [PATCH] Trap the SSL npn protocols attribute error on Python 3.10 (#151) only set npn if it exists --- grpclib/client.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/grpclib/client.py b/grpclib/client.py index ba4a549..a47b038 100644 --- a/grpclib/client.py +++ b/grpclib/client.py @@ -752,10 +752,8 @@ class Channel: ctx.options |= (_ssl.OP_NO_TLSv1 | _ssl.OP_NO_TLSv1_1) ctx.set_ciphers('ECDHE+AESGCM:ECDHE+CHACHA20:DHE+AESGCM:DHE+CHACHA20') ctx.set_alpn_protocols(['h2']) - try: + if _ssl.HAS_NPN: ctx.set_npn_protocols(['h2']) - except NotImplementedError: - pass return ctx