Skip to content

Commit

Permalink
Merge pull request #2491 from sopel-irc/tld-oopsies
Browse files Browse the repository at this point in the history
tld: fix regressions from type-hint cleanup
  • Loading branch information
dgw authored Jul 17, 2023
2 parents a620c14 + 1125d87 commit 37e6249
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sopel/modules/tld.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def get_processed_data(self):
# cache parsed data for future requests to this parser
self.parsed = tld_list

return self.tables
return self.parsed


def _update_tld_data(bot, which, force=False):
Expand Down Expand Up @@ -260,11 +260,15 @@ def _update_tld_data(bot, which, force=False):
elif which == 'data':
data_pages = []
for title in WIKI_PAGE_NAMES:
# don't one-liner this; dict.update() returns None, not the updated dict
parameters = WIKI_API_PARAMS.copy()
parameters.update({"page": title})

try:
# https://www.mediawiki.org/wiki/Special:MyLanguage/API:Get_the_contents_of_a_page
tld_response = requests.get(
"https://en.wikipedia.org/w/api.php",
params=WIKI_API_PARAMS.copy().update({"page": title}),
params=parameters,
).json()
data_pages.append(tld_response["parse"]["text"])
# py <3.5 needs ValueError instead of more specific json.decoder.JSONDecodeError
Expand Down

0 comments on commit 37e6249

Please sign in to comment.