jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/862270 )
Change subject: [IMPR] use pathlib instead of codecs for reflinks.py ......................................................................
[IMPR] use pathlib instead of codecs for reflinks.py
Change-Id: Ib2315249fd4c210e8f1649ffa45c4247e19b2c6c --- M scripts/reflinks.py 1 file changed, 12 insertions(+), 3 deletions(-)
Approvals: D3r1ck01: Looks good to me, approved Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/reflinks.py b/scripts/reflinks.py index 9fbd2f5..eb673b2 100755 --- a/scripts/reflinks.py +++ b/scripts/reflinks.py @@ -46,7 +46,6 @@ # # Distributed under the terms of the MIT license. # -import codecs import http.client as httplib import itertools import os @@ -57,6 +56,7 @@ from enum import IntEnum from functools import partial from http import HTTPStatus +from pathlib import Path from textwrap import shorten
import pywikibot @@ -527,8 +527,8 @@ def setup(self): """Read dead links from file.""" try: - with codecs.open(listof404pages, 'r', 'latin_1') as f: - self.dead_links = f.read() + path = Path(listof404pages) + self.dead_links = path.read_text(encoding='latin_1') except OSError: raise NotImplementedError( '404-links.txt is required for reflinks.py\n'