jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1059454?usp=email )
Change subject: [fix] Ignore LookupError when decoding meta content
......................................................................
[fix] Ignore LookupError when decoding meta content
Use site`s default encoding instead
Bug: T371687
Change-Id: I1144fd74b924c1713d259f46476c089e813ebdd1
---
M scripts/reflinks.py
1 file changed, 5 insertions(+), 4 deletions(-)
Approvals:
Rubin: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 5607c9c..9938011 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -553,7 +553,6 @@
raw_text = textlib.removeDisabledParts(new_text)
# for each link to change
for match in linksInRef.finditer(raw_text):
-
link = match['url']
if 'jstor.org' in link:
# TODO: Clean URL blacklist
@@ -647,10 +646,12 @@
if meta_content:
tag = None
- encodings = [encoding] if encoding else []
- encodings += list(page.site.encodings())
+ # use a dict to keep the order
+ encodings = {encoding: None} if encoding else {}
+ encodings.update(dict.fromkeys(page.site.encodings()))
+
for enc in encodings:
- with suppress(UnicodeDecodeError):
+ with suppress(UnicodeDecodeError, LookupError):
tag = meta_content.group().decode(enc)
break
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1059454?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1144fd74b924c1713d259f46476c089e813ebdd1
Gerrit-Change-Number: 1059454
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Rubin <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Matěj Suchánek <[email protected]>
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]