Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Feb 1, 2022

Conversation

fundthmcalculus
Copy link
Contributor

@fundthmcalculus fundthmcalculus commented Jan 25, 2022

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
Copy link
Owner

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
Copy link
Contributor Author

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

@fundthmcalculus
Copy link
Contributor Author

@vmagamedov updated with your requested change.

grpclib/client.py Outdated Show resolved Hide resolved
grpclib/client.py Outdated Show resolved Hide resolved
@vmagamedov vmagamedov merged commit d89bc05 into vmagamedov:master Feb 1, 2022
@vmagamedov
Copy link
Owner

Thanks! Will make a release candidate shortly.

@fundthmcalculus fundthmcalculus deleted the fix-issue-150 branch February 1, 2022 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError: 'SSLContext' object has no attribute '_set_npn_protocols' in Python 3.10
2 participants