jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[fix] pass None instead or an empty string for expiry argument

Bug: T367176
Change-Id: I12617d6d709cc37a8d5e9465f0422a26117f25b1
---
M pywikibot/page/_basepage.py
M pywikibot/site/_apisite.py
2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py
index 51d8438..9890e8d 100644
--- a/pywikibot/page/_basepage.py
+++ b/pywikibot/page/_basepage.py
@@ -2148,8 +2148,9 @@
protections dictionary.

Expiry of protections can be set via *kwargs*, see
- :meth:`Site.protect()<pywikibot.site._apisite.APISite.protect>` for
- details. By default there is no expiry for the protection types.
+ :meth:`Site.protect()<pywikibot.site._apisite.APISite.protect>`
+ for details. By default there is no expiry for the protection
+ types.

.. seealso::
- :meth:`Site.protect()
@@ -2162,10 +2163,10 @@
Defaults to protections is None, which means unprotect all
protection types.

- Example: ``{'move': 'sysop', 'edit': 'autoconfirmed'}``
+ Example: :code:`{'move': 'sysop', 'edit': 'autoconfirmed'}`

- :param reason: Reason for the action, default is None and will set an
- empty string.
+ :param reason: Reason for the action, default is None and will
+ set an empty string.
"""
protections = protections or {} # protections is converted to {}
reason = reason or '' # None is converted to ''
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 417fb99..5ca39e4 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -2760,9 +2760,10 @@
"""(Un)protect a wiki page. Requires *protect* right.

.. seealso::
- - :api:`Protect`
+ - :meth:`page.BasePage.protect`
- :meth:`protection_types`
- :meth:`protection_levels`
+ - :api:`Protect`

:param protections: A dict mapping type of protection to
protection level of that type. Refer :meth:`protection_types`
@@ -2781,11 +2782,15 @@
protections_list = [ptype + '=' + level
for ptype, level in protections.items()
if level is not None]
- parameters = merge_unique_dicts(kwargs, action='protect', title=page,
- token=token,
- protections=protections_list,
- reason=reason,
- expiry=expiry)
+ parameters = merge_unique_dicts(
+ kwargs,
+ action='protect',
+ title=page,
+ token=token,
+ protections=protections_list,
+ reason=reason,
+ expiry=expiry or None, # pass None instead of empty str
+ )

req = self.simple_request(**parameters)
try:

To view, visit change 1041651. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I12617d6d709cc37a8d5e9465f0422a26117f25b1
Gerrit-Change-Number: 1041651
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot