jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[fix] Ensure title is printed in ValueError

An empty string was printed if initialized from a link or page

Change-Id: I610ee30318a349b8c53666f94ab0b77f1bd18c44
---
M pywikibot/page/__init__.py
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index c955d98..9b8b067 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -2359,7 +2359,8 @@
self._file_revisions = {} # dictionary to cache File history.
super().__init__(source, title, 6)
if self.namespace() != 6:
- raise ValueError("'%s' is not in the file namespace!" % title)
+ raise ValueError("'{}' is not in the file namespace!"
+ .format(self.title()))

def _load_file_revisions(self, imageinfo):
for file_rev in imageinfo:
@@ -2634,8 +2635,8 @@
self.sortKey = sort_key
super().__init__(source, title, ns=14)
if self.namespace() != 14:
- raise ValueError("'%s' is not in the category namespace!"
- % title)
+ raise ValueError("'{}' is not in the category namespace!"
+ .format(self.title()))

@deprecated_args(sortKey='sort_key')
def aslink(self, sort_key: Optional[str] = None) -> str:
@@ -2951,8 +2952,8 @@
self._isAutoblock = False
super().__init__(source, title, ns=2)
if self.namespace() != 2:
- raise ValueError("'%s' is not in the user namespace!"
- % title)
+ raise ValueError("'{}' is not in the user namespace!"
+ .format(self.title()))
if self._isAutoblock:
# This user is probably being queried for purpose of lifting
# an autoblock.

To view, visit change 649114. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I610ee30318a349b8c53666f94ab0b77f1bd18c44
Gerrit-Change-Number: 649114
Gerrit-PatchSet: 1
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged