jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1152436?usp=email )
Change subject: IMPR: replace codecs.open() with pathlib methods in
pagefromfile.py
......................................................................
IMPR: replace codecs.open() with pathlib methods in pagefromfile.py
Bug: T395187
Change-Id: I4f5b7deaef2da6eb15f5846e90554db1ef9b2ef3
---
M scripts/pagefromfile.py
1 file changed, 4 insertions(+), 6 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index 1217bbf..009c3e4 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -71,15 +71,15 @@
between them by specifying '\n' as a value.
"""
#
-# (C) Pywikibot team, 2004-2024
+# (C) Pywikibot team, 2004-2025
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
-import codecs
import os
import re
+from pathlib import Path
import pywikibot
from pywikibot import config, i18n
@@ -231,11 +231,9 @@
changed from iterator method to generator property
"""
pywikibot.info(f"\n\nReading '{self.filename}'...")
+ filepath = Path(self.filename)
try:
- with codecs.open(self.filename, 'r',
- encoding=config.textfile_encoding) as f:
- text = f.read()
-
+ text = filepath.read_text(encoding=config.textfile_encoding)
except OSError as e:
pywikibot.error(e)
return
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1152436?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: I4f5b7deaef2da6eb15f5846e90554db1ef9b2ef3
Gerrit-Change-Number: 1152436
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]