jenkins-bot has submitted this change and it was merged.
Change subject: Fix API write assert
......................................................................
Fix API write assert
Cyclic recusion was introduced in
I80971cde07651a042ef6472dc1a81cb4a1704742
Use _extensions instead of _siteinfo to determine whether to
check the list of extensions.
Also wrap clauses in brackets to dictate precedence of the
and/or operators.
Change-Id: I19858792673d2a22417f8cd41e2a2881a725b189
---
M pywikibot/data/api.py
1 file changed, 12 insertions(+), 8 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 30b8415..2bdb78a 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -144,18 +144,22 @@
)
# MediaWiki 1.23 allows assertion for any action,
# whereas earlier WMF wikis and others used an extension which
- # could only allow assert for action=edit. Do not look up
- # the extension info if the siteinfo has not been loaded,
- # otherwise cyclic recursion will occur.
-
- # Check siteinfo has not been loaded to avoid infinite loop
- if hasattr(self.site, "_siteinfo"):
+ # could only allow assert for action=edit.
+ #
+ # When we can't easily check whether the extension is loaded,
+ # to avoid cyclic recursion in the Pywikibot codebase, assume
+ # that it is present, which will cause a API warning emitted
+ # to the logging (console) if it is not present, but will not
+ # otherwise be a problem.
+ # This situation is only tripped when one of the first actions
+ # on the site is a write action and the extension isn't installed.
+ if hasattr(self.site, "_extensions"):
use_assert_edit_extension = self.site.hasExtension('AssertEdit',
False)
else:
use_assert_edit_extension = True
- if (self.write and LV(self.site.version()) >= LV("1.23") or
- self.params["action"] == "edit" and
use_assert_edit_extension):
+ if ((self.write and LV(self.site.version()) >= LV("1.23")) or
+ (self.params["action"] == "edit" and
use_assert_edit_extension)):
pywikibot.debug(u"Adding user assertion", _logger)
self.params["assert"] = "user" # make sure user is
logged in
--
To view, visit
https://gerrit.wikimedia.org/r/153007
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I19858792673d2a22417f8cd41e2a2881a725b189
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>