From c743861400e8a5d680104c61218f93d16790b11e Mon Sep 17 00:00:00 2001 From: dgw Date: Thu, 3 Aug 2023 10:08:37 -0700 Subject: [PATCH] tld: be more specific about JSONDecodeError instead of ValueError As of Python 3.5, we can do this. It's overdue. --- sopel/modules/tld.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel/modules/tld.py b/sopel/modules/tld.py index 3ef96072f..33a23cd88 100644 --- a/sopel/modules/tld.py +++ b/sopel/modules/tld.py @@ -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 @@ -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.',