jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/649370 )
Change subject: [cleanup] remove desupported PageRelatedError.getPage method ......................................................................
[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(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
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):
pywikibot-commits@lists.wikimedia.org