jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] QueryGenerator: Allow missing 'query' entry ......................................................................
[FIX] QueryGenerator: Allow missing 'query' entry
The QueryGenerator stopped when the result didn't contain a 'query' entry. If the result doesn't contain anything yet (but needs to be continued) it's not returning a 'query' entry when used with the 'generator' API feature.
Instead of stopping the iteration when there is not 'query' entry it's just stopping the iteration if there is no continuation provided. Because the exact nature why the condition was there in the first place (it was added in 54bc6aafa591e31274dc3630e9c6c1039f80839b) is not known the output was raised from 'debug' to 'log'. Prior to that revision no condition was found in the repository which looks like that.
Bug: T84860 Change-Id: I1f8c4986d69be18134987c951fd65237300e277e --- M pywikibot/data/api.py M tests/category_tests.py 2 files changed, 5 insertions(+), 12 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved Unicodesnowman: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 04420c2..5b70fe1 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1483,14 +1483,7 @@ % self.__class__.__name__, _logger) return - if "query" not in self.data: - pywikibot.debug( - u"%s: stopped iteration because 'query' not found in api " - u"response." % self.__class__.__name__, - _logger) - pywikibot.debug(unicode(self.data), _logger) - return - if self.resultkey in self.data["query"]: + if 'query' in self.data and self.resultkey in self.data["query"]: resultdata = self.data["query"][self.resultkey] if isinstance(resultdata, dict): pywikibot.debug(u"%s received %s; limit=%s" @@ -1538,6 +1531,10 @@ # self.resultkey in data in last request.submit() previous_result_had_data = True else: + if 'query' not in self.data: + pywikibot.log("%s: 'query' not found in api response." % + self.__class__.__name__) + pywikibot.log(unicode(self.data)) # if (query-)continue is present, self.resultkey might not have # been fetched yet if self.continue_name not in self.data: diff --git a/tests/category_tests.py b/tests/category_tests.py index 6ba5abb..9e57069 100644 --- a/tests/category_tests.py +++ b/tests/category_tests.py @@ -11,7 +11,6 @@ import pywikibot.page
from tests.aspects import unittest, TestCase -from tests.utils import allowed_failure
class TestCategoryObject(TestCase): @@ -100,11 +99,8 @@ subcategories_total = list(cat.subcategories(total=2)) self.assertEqual(len(subcategories_total), 2)
- @allowed_failure def test_subcategories_recurse(self): """Test the subcategories method with recurse=True.""" - # FIXME: Broken, some subcategories are missing. - # See: T84860 site = self.get_site() cat = pywikibot.Category(site, 'Category:Wikipedians by gender') c1 = pywikibot.Category(site, 'Category:Female Wikipedians')
pywikibot-commits@lists.wikimedia.org