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)


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iab076d7f8caede9e3caefeb3218112358cd8bfe4
Gerrit-Change-Number: 817716
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: MarcoAurelio <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: PotsdamLamb
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to