jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/335254 )
Change subject: APISite.data_repository(): handle warning with re.match() ......................................................................
APISite.data_repository(): handle warning with re.match()
In 4e6810e, the message was added to i18n. During the process, the message changed: a period was added to the end, and the single quotation marks (') were changed to <var> tag, which in turn creates double quotation marks ("). However, luckily, the warning (somehow converted from an error internally in MediaWiki) seems to stay in English regardless of which site we are operating on.
Like the other places where req._warning_handler is used, here, to maintain backwards compatibility, we regex-compare the warning to account for the changes to the warning message. The regex itself is not wrapped after 80 characters due to that wrapping a string would be easily confused with wrapping multiple parameters.
Bug: T156596 Change-Id: I47436809960de23746eeb4877a9919772ce11448 --- M pywikibot/site.py 1 file changed, 2 insertions(+), 2 deletions(-)
Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index f2724d9..2491a54 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -2761,8 +2761,8 @@ """ def handle_warning(mod, warning): return (mod == 'query' and - warning == "Unrecognized value for parameter 'meta': " - "wikibase") + re.match(r'Unrecognized value for parameter ['"]meta['"]: wikibase', + warning))
req = self._simple_request(action='query', meta='wikibase') req._warning_handler = handle_warning
pywikibot-commits@lists.wikimedia.org