vmagamedov / grpclib

Pure-Python gRPC implementation for asyncio
http://grpclib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
936 stars 92 forks source link

Trap the SSL npn protocols attribute error on Python 3.10 #151

Closed fundthmcalculus closed 2 years ago

fundthmcalculus commented 2 years ago

closes #150 @vmagamedov this fix allows grpclib to run on Python 3.10, by trapping the additional attribute error due to npn protocol being removed. Getting this integrated into the next RC would be ideal.

vmagamedov commented 2 years ago

Looks like a bug in Python because set_npn_protocols method still exists and is documented in Python 3.10.2: SSLContext.set_npn_protocols. NotImplementedError should be raised instead of AttributeError.

Instead of catching AttributeError (and NotImplementedError), which looks not very specific to me, I propose to check ssl.HAS_NPN constant and to call set_npn_protocols only if ssl.HAS_NPN == True.

fundthmcalculus commented 2 years ago

That would be a better solution, since this is a bug in Python. Let me make those changes.

fundthmcalculus commented 2 years ago

@vmagamedov updated with your requested change.

vmagamedov commented 2 years ago

Thanks! Will make a release candidate shortly.