jenkins-bot merged this change.

View Change

Approvals: Zhuyifei1999: Looks good to me, approved jenkins-bot: Verified
[bugfix] ensure "modules" parameter of ParamInfo._fetch is a set

Bug: T122763
Change-Id: I896b8cdd85bed894c23824f31c99f3b86f36257c
---
M pywikibot/data/api.py
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index f7e4745..1b86cf5 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Interface to Mediawiki's api.php."""
#
-# (C) Pywikibot team, 2007-2018
+# (C) Pywikibot team, 2007-2019
#
# Distributed under the terms of the MIT license.
#
@@ -541,6 +541,17 @@

self._emulate_pageset()

+ @staticmethod
+ def _modules_to_set(modules):
+ """Return modules as a set.
+
+ @type modules: iterable or basestring
+ @rtype: set
+ """
+ if isinstance(modules, basestring):
+ return set(modules.split('|'))
+ return set(modules)
+
def fetch(self, modules):
"""
Fetch paraminfo for multiple modules.
@@ -557,6 +568,8 @@
# query modules can be prefixed with 'query+'
self._init()

+ modules = self._modules_to_set(modules)
+
if self._action_modules:
# The query module may be added before the action modules have been
if 'query' in self._modules:
@@ -740,8 +753,7 @@
def _normalize_modules(self, modules):
"""Add query+ to any query module name not also in action modules."""
# Users will supply the wrong type, and expect it to work.
- if isinstance(modules, basestring):
- modules = set(modules.split('|'))
+ modules = self._modules_to_set(modules)

assert(self._action_modules)


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I896b8cdd85bed894c23824f31c99f3b86f36257c
Gerrit-Change-Number: 423701
Gerrit-PatchSet: 7
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)