jenkins-bot submitted this change.

View Change


Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[bugfix]: use only 'end' tags in ElementTree.iterparse

See note in iterparse() official docs.

Bug: T354095
Change-Id: Id3498ad90c266aff5e98c79ff08bcc8f14a0bfac
---
M pywikibot/xmlreader.py
1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/pywikibot/xmlreader.py b/pywikibot/xmlreader.py
index 5d3575e..a01c4d4 100644
--- a/pywikibot/xmlreader.py
+++ b/pywikibot/xmlreader.py
@@ -18,7 +18,6 @@
from __future__ import annotations

import re
-from typing import Optional, Union


try:
@@ -124,11 +123,11 @@
"""

def __init__(self, filename, *,
- allrevisions: Union[bool, str] = None,
+ allrevisions: bool | str = None,
# when allrevisions removed, revisions can default to 'latest'
revisions: str = 'first_found',
- on_error: Optional[
- Callable[[Type[BaseException]], None]] = None) -> None:
+ on_error: None | (
+ Callable[[Type[BaseException]], None]) = None) -> None:
"""Initializer."""
self.filename = filename
self.on_error = on_error
@@ -237,10 +236,10 @@

def _parse_all(self, event, elem):
"""Parser that yields all revisions."""
- if event == 'start' and elem.tag == f'{{{self.uri}}}page':
+ if event == 'end' and elem.tag == f'{{{self.uri}}}page':
self._headers(elem)
- if event == 'end' and elem.tag == f'{{{self.uri}}}revision':
- yield self._create_revision(elem)
+ for revision in elem.findall(f'{{{self.uri}}}revision'):
+ yield self._create_revision(revision)
elem.clear()
self.root.clear()


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Id3498ad90c266aff5e98c79ff08bcc8f14a0bfac
Gerrit-Change-Number: 986537
Gerrit-PatchSet: 1
Gerrit-Owner: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged