Skip to content

fix: handles BSI query URL exception or SSL errors for python 3.8 to 3.11 #231

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

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion csep/utils/comcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ def _search(**newargs):

except URLError as URLe:
# Fails to verify SSL certificate, when there is a hostname mismatch
if isinstance(URLe.reason, ssl.SSLCertVerificationError) and URLe.reason.verify_code == 62:
if (isinstance(URLe.reason, ssl.SSLCertVerificationError) and URLe.reason.verify_code == 62) \
or (isinstance(URLe.reason, ssl.SSLError) and URLe.reason.errno == 5):
Comment on lines +316 to +317
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added additional reason and error code to make this compatible with Python 3.8-3.11.

try:
context = ssl._create_unverified_context()
fh = request.urlopen(url, timeout=TIMEOUT, context=context)
Expand Down