Skip to content

Commit

Permalink
tld: be more specific about JSONDecodeError instead of ValueError
Browse files Browse the repository at this point in the history
As of Python 3.5, we can do this. It's overdue.
  • Loading branch information
dgw committed Aug 3, 2023
1 parent 57b692c commit c743861
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sopel/modules/tld.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datetime import datetime
from encodings import idna
from html.parser import HTMLParser
from json import JSONDecodeError
import logging
import re
from typing import Union
Expand Down Expand Up @@ -271,8 +272,7 @@ def _update_tld_data(bot, which, force=False):
params=parameters,
).json()
data_pages.append(tld_response["parse"]["text"])
# py <3.5 needs ValueError instead of more specific json.decoder.JSONDecodeError
except (requests.exceptions.RequestException, ValueError, KeyError):
except (requests.exceptions.RequestException, JSONDecodeError, KeyError):
# Log error and continue life; it'll be fine
LOGGER.warning(
'Error fetching TLD data from "%s" on Wikipedia; will try again later.',
Expand Down

0 comments on commit c743861

Please sign in to comment.