jenkins-bot submitted this change.

View Change

Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
[cleanup] remove desupported PageRelatedError.getPage method

Also fix string formatting and require r'%\(\w+\)s' as given pattern

Change-Id: I2d61fbec87c23fdfb1b5cf14af6cbf13f3a4a82d
---
M pywikibot/exceptions.py
1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 709adfe..62a2bb7 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -86,9 +86,11 @@
#
# Distributed under the terms of the MIT license.
#
+import re
+
from typing import Optional, Union

-from pywikibot.tools import deprecated, _NotImplementedWarning
+from pywikibot.tools import _NotImplementedWarning


class NotImplementedWarning(_NotImplementedWarning):
@@ -155,16 +157,11 @@
self.title = page.title(as_link=True)
self.site = page.site

- if '%(' in self.message and ')s' in self.message:
- super().__init__(self.message % self.__dict__)
+ if re.search(r'%\(\w+\)s', self.message):
+ values = self.__dict__
else:
- super().__init__(self.message % page)
-
- @deprecated('PageRelatedError.page attribute', since='20201016',
- future_warning=True)
- def getPage(self):
- """DEPRECATED. Return the page related to the exception."""
- return self.page
+ values = page
+ super().__init__(self.message % values)


class PageSaveRelatedError(PageRelatedError):

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2d61fbec87c23fdfb1b5cf14af6cbf13f3a4a82d
Gerrit-Change-Number: 649370
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged