jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1136118?usp=email )
Change subject: [bugfix] skip removeEmptySections() if section length is too less
......................................................................
[bugfix] skip removeEmptySections() if section length is too less
skip removeEmptySections() if section length is lower than
skip_section. There must be something wrong but check it later.
Bug: T391776
Change-Id: I5d4e71c36b9f67f0b489b906164fa7da6a479b1e
---
M pywikibot/cosmetic_changes.py
1 file changed, 5 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 463e346..b7e25d6 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -731,12 +731,17 @@
stripped_text = textlib.removeLanguageLinks(text, self.site, '\n')
for reg in skip_regexes:
stripped_text = reg.sub(r'', stripped_text)
+
strip_sections = textlib.extract_sections(
stripped_text, self.site).sections
# get proper sections
header, sections, footer = textlib.extract_sections(text, self.site)
+ if len(strip_sections) > len(sections):
+ # there must be something wrong with the extracted sections; skip
+ return text
+
# iterate stripped sections and create a new page body
new_body: list[textlib.Section] = []
for i, strip_section in enumerate(strip_sections):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1136118?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: I5d4e71c36b9f67f0b489b906164fa7da6a479b1e
Gerrit-Change-Number: 1136118
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot