jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1224896?usp=email )

Change subject: FIX: Handle limit value gracefully if it is an int
......................................................................

FIX: Handle limit value gracefully if it is an int

Bug: T414168
Change-Id: Ie49f8aeef067777fa5ba042a1330d2f68557e05a
---
M pywikibot/data/api/_requests.py
1 file changed, 6 insertions(+), 5 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index d77a0c6..a8289f0 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -1,6 +1,6 @@
 """Objects representing API requests."""
 #
-# (C) Pywikibot team, 2007-2025
+# (C) Pywikibot team, 2007-2026
 #
 # Distributed under the terms of the MIT license.
 #
@@ -9,6 +9,7 @@
 import datetime
 import hashlib
 import inspect
+import math
 import os
 import pickle
 import pprint
@@ -797,10 +798,10 @@
             # there might also be an overflow, so try a smaller limit
             for param in self._params:
                 if param.endswith('limit'):
-                    # param values are stored a list of str
-                    value = self[param][0]
-                    if value.isdigit():
-                        self[param] = [str(int(value) // 2)]
+                    # param values are stored a list of str or int (T414168)
+                    with suppress(ValueError):
+                        value = int(self[param][0])
+                        self[param] = [str(math.ceil(value / 2))]
                         pywikibot.info(f'Set {param} = {self[param]}')
         else:
             scheme = urlparse(response.url).scheme

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1224896?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ie49f8aeef067777fa5ba042a1330d2f68557e05a
Gerrit-Change-Number: 1224896
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to