jenkins-bot has submitted this change and it was merged.

Change subject: QueryGen.set_namespace: no request param if empty
......................................................................


QueryGen.set_namespace: no request param if empty

If namespaces is None, [], or other empty iterator,
assume the caller is not wanting to restrict the
namespaces to 'no namespace', as that would prevent
any data from being returned.

Change-Id: I8224976fce0559c2663025d99dd86f55efe8e538
---
M pywikibot/data/api.py
1 file changed, 7 insertions(+), 2 deletions(-)

Approvals:
  XZise: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 5d3b2ff..5cdc466 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1740,7 +1740,8 @@
         @param namespaces: namespace identifiers to limit query results
         @type namespaces: iterable of basestring or Namespace key,
             or a single instance of those types.  May be a '|' separated
-            list of namespace identifiers.
+            list of namespace identifiers. An empty iterator clears any
+            namespace restriction.
         @raises KeyError: a namespace identifier was not resolved
         @raises TypeError: a namespace identifier has an inappropriate
             type such as NoneType or bool, or more than one namespace
@@ -1760,11 +1761,15 @@
         namespaces = [ns.id for ns in
                       pywikibot.site.Namespace.resolve(namespaces,
                                                        self.site.namespaces)]
+
         if 'multi' not in param and len(namespaces) != 1:
             raise TypeError(u'{0} module does not support multiple namespaces'
                             .format(self.limited_module))
 
-        self.request[self.prefix + "namespace"] = namespaces
+        if namespaces:
+            self.request[self.prefix + 'namespace'] = namespaces
+        elif self.prefix + 'namespace' in self.request:
+            del self.request[self.prefix + 'namespace']
 
     def _query_continue(self):
         if all(key not in self.data[self.continue_name]

-- 
To view, visit https://gerrit.wikimedia.org/r/186734
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8224976fce0559c2663025d99dd86f55efe8e538
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to