jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/680379 )
Change subject: [IMPR] catch LocationParseError in reflinks.py ......................................................................
[IMPR] catch LocationParseError in reflinks.py
- urllib3.LocationParseError derives from ValueError. Ignore this exception and continue with next link - remove URLError because urllib is no longer used
Bug: T280356 Change-Id: I7414fc580dd28343e9ceb3c6f145cc5d8ad877d9 --- M pywikibot/comms/http.py M scripts/reflinks.py 2 files changed, 5 insertions(+), 5 deletions(-)
Approvals: Rubin: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index 65cddd1..ecb9f90 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -291,7 +291,7 @@
if isinstance(response, Exception): with suppress(Exception): - # request.data exception may contain response and request attribute + # request exception may contain response and request attribute error('An error occurred for uri ' + response.request.url) raise response from None
diff --git a/scripts/reflinks.py b/scripts/reflinks.py index 7044c21..0bfeb95 100755 --- a/scripts/reflinks.py +++ b/scripts/reflinks.py @@ -51,7 +51,6 @@ from functools import partial from http import HTTPStatus from textwrap import shorten -from urllib.error import URLError
import pywikibot
@@ -605,15 +604,16 @@ ref.url, page.title(as_link=True))) continue
- except (URLError, + except (ValueError, # urllib3.LocationParseError derives from it socket.error, IOError, httplib.error, pywikibot.FatalServerError, pywikibot.Server414Error, pywikibot.Server504Error) as e: - pywikibot.output("Can't retrieve page {} : {}" - .format(ref.url, e)) + pywikibot.output( + "{err.__class__.__name__}: Can't retrieve url {url}: {err}" + .format(url=ref.url, err=e)) continue
linkedpagetext = r.content
pywikibot-commits@lists.wikimedia.org