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

Change subject: (bug 58976) Do not get() the item straight after preloading it.
......................................................................


(bug 58976) Do not get() the item straight after preloading it.

The ItemPage.get() raises the NoPage exception if it does not exists.
It's not possible to catch this and return to the iterator:

try:
    for page in preloaditempages():
        # do something with page
except NoPage:
    # ??? No way to continue processing the next page

By removing the internal .get(), we allow the following:

for page in preloaditempages():
    # page is not guaranteed to exist now
    try:
        # do something with page
    except NoPage:
        # print an error
        continue # with the next page

Change-Id: I9e09ba42e4562a962731f6c2cca70c020901828f
---
M pywikibot/site.py
1 file changed, 0 insertions(+), 1 deletion(-)

Approvals:
  Merlijn van Deen: Looks good to me, approved
  Multichill: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/site.py b/pywikibot/site.py
index a090d04..31ef5b2 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3621,7 +3621,6 @@
             for qid in data['entities']:
                 item = pywikibot.ItemPage(self, qid)
                 item._content = data['entities'][qid]
-                item.get()  # parses json and preloads the various properties
                 yield item
 
     def getPropertyType(self, prop):

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9e09ba42e4562a962731f6c2cca70c020901828f
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Multichill <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to