Mpaa submitted this change.

View Change

Approvals: Mpaa: Looks good to me, approved Xqt: Verified
[BUGFIX] Exit loop in PageFromFileReader if match.end() <= 0

Bug: T313684
Change-Id: I797dbc1f7d12a84740e2ffab2d6b233087e159b2
---
M scripts/pagefromfile.py
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index a29606f..f1809c2 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -213,28 +213,25 @@
pywikibot.error(e)
return

- position = 0
length = 0
- while True:
+ while text:
try:
- length, title, contents = self.findpage(text[position:])
+ length, title, contents = self.findpage(text)
except AttributeError:
if not length:
pywikibot.output('\nStart or end marker not found.')
else:
pywikibot.output('End of file.')
break
+
except NoTitleError as err:
pywikibot.output('\nNo title found - skipping a page.')
- position += err.offset
- continue
- if length == 0:
- break
- position += length
-
- page = pywikibot.Page(self.site, title)
- setattr(page, CTX_ATTR, contents.strip())
- yield page
+ text = text[err.offset:]
+ else:
+ page = pywikibot.Page(self.site, title)
+ setattr(page, CTX_ATTR, contents.strip())
+ yield page
+ text = text[length:]

def findpage(self, text) -> Tuple[int, str, str]:
"""Find page to work on."""

To view, visit change 816295. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I797dbc1f7d12a84740e2ffab2d6b233087e159b2
Gerrit-Change-Number: 816295
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged