Attention is currently required from: PywikibotCommitWatcher.
AtharvaKathe has posted comments on this change by AtharvaKathe. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1230405?usp=email )
Change subject: Fix: validate 'start' parameter in parse_start and raise ValueError on invalid formats
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Hi! Could I get a review on this patch? It adds stricter validation for the parse_start() helper in logevents.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1230405?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4ef16fbcb7059bf137d47095564f508765e12ccf
Gerrit-Change-Number: 1230405
Gerrit-PatchSet: 1
Gerrit-Owner: AtharvaKathe <atharvakathe567(a)gmail.com>
Gerrit-Reviewer: AtharvaKathe <atharvakathe567(a)gmail.com>
Gerrit-Reviewer: PywikibotCommitWatcher <pywikibot-commits(a)lists.wikimedia.org>
Gerrit-Attention: PywikibotCommitWatcher <pywikibot-commits(a)lists.wikimedia.org>
Gerrit-Comment-Date: Thu, 22 Jan 2026 19:01:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: PywikibotCommitWatcher.
Hello PywikibotCommitWatcher,
I'd like you to do a code review.
Please visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1230405?usp=email
to review the following change.
Change subject: Fix: validate 'start' parameter in parse_start and raise ValueError on invalid formats
......................................................................
Fix: validate 'start' parameter in parse_start and raise ValueError on invalid formats
Improved input handling in parse_start by detecting invalid timestamp
strings and raising a clear ValueError instead of silently converting them.
This matches expected behavior in LogeventsPageGenerator and ensures
better consistency with test expectations.
Change-Id: I4ef16fbcb7059bf137d47095564f508765e12ccf
---
M pywikibot/pagegenerators/_factory.py
1 file changed, 13 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/05/1230405/1
diff --git a/pywikibot/pagegenerators/_factory.py b/pywikibot/pagegenerators/_factory.py
index 22d5201..bcd1dfa 100644
--- a/pywikibot/pagegenerators/_factory.py
+++ b/pywikibot/pagegenerators/_factory.py
@@ -387,22 +387,24 @@
value.
"""
def parse_start(
- start: str | None
- ) -> tuple[pywikibot.Timestamp | None, int | None]:
+ start: str | None,
+ ) -> tuple[Optional[pywikibot.Timestamp], Optional[int]]:
"""Parse start and return (start, total)."""
if not start:
return None, None
- if len(start) >= 8:
- return pywikibot.Timestamp.fromtimestampformat(start), None
+ # If start looks like timestamp → treat as timestamp
+ if len(start) >= 8 and start.isdigit():
+ try:
+ return pywikibot.Timestamp.fromtimestampformat(start), None
+ except Exception as err:
+ raise ValueError(f"Invalid timestamp format: {err}") from err
- instead = (f'-limit option like "-logevents:{logtype}'
- f'{"," if user else ""}{user} -limit:{start}"')
- issue_deprecation_warning('-logevents with total argument',
- instead,
- warning_class=ArgumentDeprecationWarning,
- since='9.2.0')
- return None, int(start)
+ # If NOT timestamp → treat as total number
+ if start.isdigit():
+ return None, int(start)
+
+ raise ValueError("Start must be timestamp (>=8 digits) or a positive integer.")
try:
start_, total = parse_start(start)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1230405?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4ef16fbcb7059bf137d47095564f508765e12ccf
Gerrit-Change-Number: 1230405
Gerrit-PatchSet: 1
Gerrit-Owner: AtharvaKathe <atharvakathe567(a)gmail.com>
Gerrit-Reviewer: AtharvaKathe <atharvakathe567(a)gmail.com>
Gerrit-Reviewer: PywikibotCommitWatcher <pywikibot-commits(a)lists.wikimedia.org>
Gerrit-Attention: PywikibotCommitWatcher <pywikibot-commits(a)lists.wikimedia.org>
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1228281?usp=email )
Change subject: Optimize SubCategoriesPageGenerator (fix error too many requests)
......................................................................
Optimize SubCategoriesPageGenerator (fix error too many requests)
Change-Id: I3f3f4a721799ffaffaac455f2b674b74e3f618e5
---
M pywikibot/pagegenerators/_generators.py
1 file changed, 3 insertions(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/pagegenerators/_generators.py b/pywikibot/pagegenerators/_generators.py
index 1b76e1d..2579492 100644
--- a/pywikibot/pagegenerators/_generators.py
+++ b/pywikibot/pagegenerators/_generators.py
@@ -378,11 +378,9 @@
:param content: If True, retrieve the content of the current version
of each page (default False)
"""
- # TODO: page generator could be modified to use cmstartsortkey ...
- for s in category.subcategories(recurse=recurse,
- total=total, content=content):
- if start is None or s.title(with_ns=False) >= start:
- yield s
+ return category.subcategories(recurse=recurse,
+ total=total, content=content,
+ startprefix=start)
def LinkedPageGenerator(
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1228281?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: I3f3f4a721799ffaffaac455f2b674b74e3f618e5
Gerrit-Change-Number: 1228281
Gerrit-PatchSet: 3
Gerrit-Owner: Louperivois <plmoell(a)hotmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225619?usp=email )
Change subject: get_delay: consider retry_after in delay calculation
......................................................................
get_delay: consider retry_after in delay calculation
Include any pending retry_after when computing the delay for read or
write operations. The returned value still incorporates process
concurrency via process_multiplicity.
Bug: T414354
Change-Id: I06e863e35cb8087b493b74bd7d7cdf958a8572f2
---
M pywikibot/throttle.py
1 file changed, 15 insertions(+), 7 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index 0fe30ad..d0fd51f 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -10,7 +10,7 @@
on the number of concurrent bot instances, and optional lag-aware delays.
"""
#
-# (C) Pywikibot team, 2008-2025
+# (C) Pywikibot team, 2008-2026
#
# Distributed under the terms of the MIT license.
#
@@ -269,25 +269,33 @@
def get_delay(self, *, write: bool = False) -> float:
"""Return the current delay, adjusted for active processes.
- Compute the delay for a read or write operation, factoring in
- process concurrency. This method does not account for how much
- time has already passed since the last access — use
+ Computes the delay for a read or write operation, taking into
+ account process concurrency and any pending retry-after value.
+ The returned value already includes the
+ :attr:`process_multiplicity` factor. This method does not
+ consider how much time has passed since the last access — use
:meth:`waittime` for that.
.. versionadded:: 10.3.0
Renamed from :meth:`getDelay`.
+ .. versionchanged:: 11.0
+ The delay now takes any pending :attr:`retry_after` into
+ account.
:param write: Whether the operation is a write (uses writedelay).
:return: The delay in seconds before the next operation should
occur.
"""
- current_delay = self.writedelay if write else self.delay
-
# Refresh process count if the check interval has elapsed
if time.time() > self.checktime + self.checkdelay:
self.checkMultiplicity()
- current_delay = max(self.mindelay, min(current_delay, self.maxdelay))
+ current_delay = max(
+ self.mindelay,
+ self.retry_after,
+ min(self.writedelay if write else self.delay, self.maxdelay)
+ )
+
return current_delay * self.process_multiplicity
def waittime(self, write: bool = False):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225619?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: I06e863e35cb8087b493b74bd7d7cdf958a8572f2
Gerrit-Change-Number: 1225619
Gerrit-PatchSet: 10
Gerrit-Owner: Shivaansh Singh <shivaanshsingh293(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1228280?usp=email )
Change subject: doc: Update documentation for api.Request
......................................................................
doc: Update documentation for api.Request
This is a follow-up patch for I1234567890abcdef1234567890abcdef12345678
Bug: T414369
Change-Id: I0709d0a18f1f18867d97cbf48f87e2762fe0ed10
---
M pywikibot/data/api/_requests.py
1 file changed, 9 insertions(+), 2 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 fe20032..7891757 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -706,6 +706,10 @@
content.
.. versionchanged:: 9.2
no wait cycles for :exc:`ImportError` and :exc:`NameError`.
+ .. versionchanged:: 11.0
+ The scheme swapping introduced in version 8.2 was removed.
+ Any :class:`Family<family.Family>` file must provide a
+ correct :meth:`protocol()<family.Family.protocol>` method.
:param use_get: If True, send a GET request; otherwise send POST.
:param uri: The URI path to request on the site.
@@ -773,8 +777,11 @@
"""Return a dict from requests.Response.
.. versionchanged:: 8.2
- show a warning to add a ``protocol()`` method to the family
- file if suitable.
+ show a warning to add a :meth:`protocol()
+ <family.Family.protocol>` method to the family file if suitable.
+ .. versionchanged:: 11.0
+ The warning about missing or wrong ``protocol()`` method
+ introduced in version 8.2 was removed.
:param response: a requests.Response object
:type response: requests.Response
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1228280?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: I0709d0a18f1f18867d97cbf48f87e2762fe0ed10
Gerrit-Change-Number: 1228280
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225150?usp=email )
Change subject: FIX: Remove invisible chars from Section.heading
......................................................................
FIX: Remove invisible chars from Section.heading
Section.heading is used to validate whether a Page.section() exists.
This may fail if the section contains invisible chars like LTR or RTL
but the MediaWiki link works. This patch removes invisible chars from
Section.heading but keeps Section title unchanged.
Bug: T411307
Change-Id: Ide04ca1b1b4eac05ae4ae7211db8496e5200f87a
---
M pywikibot/textlib.py
1 file changed, 5 insertions(+), 1 deletion(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 942cef3..5e08c36 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -22,6 +22,7 @@
from pywikibot.family import Family
from pywikibot.time import TZoneFixedOffset
from pywikibot.tools import ModuleDeprecationWrapper, first_lower, first_upper
+from pywikibot.tools.chars import INVISIBLE_REGEX
from pywikibot.userinterfaces.transliteration import NON_ASCII_DIGITS
@@ -1112,9 +1113,12 @@
"""Return the section title without equal signs.
.. versionadded:: 8.2
+ .. versionchanged:: 11.0
+ Invisible chars like LTR or RTO are removed.
"""
level = self.level
- return self.title[level:-level].strip()
+ title = self.title[level:-level].strip()
+ return INVISIBLE_REGEX.sub('', title)
class SectionList(list):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225150?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: Ide04ca1b1b4eac05ae4ae7211db8496e5200f87a
Gerrit-Change-Number: 1225150
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1227259?usp=email )
Change subject: tests: Fix ua format string result for in TestDrySite.test_user_agent
......................................................................
tests: Fix ua format string result for in TestDrySite.test_user_agent
user_agent_username() was changed to return a username set in
PYWIKIBOT_USERNAME or PWB_USERNAME environment variables
Bug: T414657
Change-Id: I6e244497844d0c6da00e13603e6a0e7c32e0ddc2
---
M tests/dry_site_tests.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py
index f9f0652..c8e492e 100755
--- a/tests/dry_site_tests.py
+++ b/tests/dry_site_tests.py
@@ -106,9 +106,9 @@
ua_username = user_agent_username()
self.assertEqual(f'Foo {ua_username}'.strip(),
user_agent(x, format_string='Foo {username}'))
- self.assertEqual(f'Foo ({x})',
- user_agent(
- x, format_string='Foo ({script_comments})'))
+ res = f'Foo ({x}; User:{ua_username})' if ua_username else f'Foo ({x})'
+ self.assertEqual(
+ res, user_agent(x, format_string='Foo ({script_comments})'))
if __name__ == '__main__':
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1227259?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: I6e244497844d0c6da00e13603e6a0e7c32e0ddc2
Gerrit-Change-Number: 1227259
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot