jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1150029?usp=email )
Change subject: IMPR: replace codecs.open with stdlib open in pagegenerators/_generators.py
......................................................................
IMPR: replace codecs.open with stdlib open in pagegenerators/_generators.py
Bug: T395187
Change-Id: Ia77843a20591bc54853a06c74dc1bdfed56f3917
---
M pywikibot/pagegenerators/_generators.py
1 file changed, 2 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators/_generators.py b/pywikibot/pagegenerators/_generators.py
index 2cf3c0e..2958652 100644
--- a/pywikibot/pagegenerators/_generators.py
+++ b/pywikibot/pagegenerators/_generators.py
@@ -7,7 +7,6 @@
from __future__ import annotations
import calendar
-import codecs
import io
import re
import typing
@@ -401,7 +400,7 @@
return linkingPage.linkedPages(total=total, content=content)
-def _yield_titles(f: codecs.StreamReaderWriter | io.StringIO,
+def _yield_titles(f: io.TextIOBase,
site: pywikibot.site.BaseSite
) -> Generator[pywikibot.page.Page, None, None]:
"""Yield page titles from a text stream.
@@ -451,7 +450,7 @@
site = pywikibot.Site()
# If source cannot be parsed as an HTTP URL, treat as local file
if not urlparse(source).netloc:
- with codecs.open(source, 'r', config.textfile_encoding) as local_file:
+ with open(source, encoding=config.textfile_encoding) as local_file:
yield from _yield_titles(local_file, site)
# Else, fetch page (page should return text in same format as that expected
# in filename, i.e. pages separated by newlines or pages enclosed in double
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1150029?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: Ia77843a20591bc54853a06c74dc1bdfed56f3917
Gerrit-Change-Number: 1150029
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot