John Vandenberg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/185785
Change subject: raise NoPage before using Page.text within Page
......................................................................
raise NoPage before using Page.text within Page
templatesWithParams and other methods previously used Page.text,
which is empty if the page does not exist, and NoPage isnt raised.
Change-Id: Icb66f305eca26fc2bb9cefad0637a4d946f0abc1
---
M pywikibot/page.py
1 file changed, 16 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/85/185785/1
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 45e41c3..e408b17 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -515,6 +515,10 @@
self._expanded_text = ''
return ''
+ # Raise NoPage
+ if not hasattr(self, '_text'):
+ self.get()
+
self._expanded_text = self.site.expand_text(
self.text,
title=self.title(withSection=False),
@@ -1182,6 +1186,10 @@
@return: a generator that yields Link objects
"""
+ # Raise NoPage
+ if not hasattr(self, '_text'):
+ self.get()
+
# This function does not exist in the API, so it has to be
# implemented by screen-scraping
if expand:
@@ -1724,6 +1732,10 @@
@rtype: bool
"""
+ # Raise NoPage
+ if not hasattr(self, '_text'):
+ self.get()
+
# get list of Category objects the article is in and remove possible
# duplicates
cats = []
@@ -1868,6 +1880,10 @@
parameters as the second entry.
"""
+ # Raise NoPage
+ if not hasattr(self, '_text'):
+ self.get()
+
# WARNING: may not return all templates used in particularly
# intricate cases such as template substitution
titles = list(t.title() for t in self.templates())
--
To view, visit https://gerrit.wikimedia.org/r/185785
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb66f305eca26fc2bb9cefad0637a4d946f0abc1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits