jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/817716 )
Change subject: [bugfix] Fix for DiscussionPage.size() ......................................................................
[bugfix] Fix for DiscussionPage.size()
If maxarchivesize is smaller than length of header no archive can be found even the page does not exist and is empty therefore. To solve this, DiscussionPage.size() returns 0 if the page does not exists and has no threads.
Bug: T313886 Change-Id: Iab076d7f8caede9e3caefeb3218112358cd8bfe4 --- M scripts/archivebot.py 1 file changed, 8 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py index 19ab8cf..aaad6ed 100755 --- a/scripts/archivebot.py +++ b/scripts/archivebot.py @@ -392,13 +392,19 @@ return self.is_full(max_archive_size)
def size(self) -> int: - """ - Return size of talk page threads. + """Return size of talk page threads.
Note that this method counts bytes, rather than codepoints (characters). This corresponds to MediaWiki's definition of page size. + + .. versionchanged:: 7.6 + return 0 if archive page neither exists nor has threads + (:phab:`T313886`). """ + if not (self.exists() or self.threads): + return 0 + return len(self.header.encode('utf-8')) + sum(t.size() for t in self.threads)
pywikibot-commits@lists.wikimedia.org