jenkins-bot submitted this change.
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(-)
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 change 1152436. To unsubscribe, or for help writing mail filters, visit settings.