jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/606830 )
Change subject: [PY3] Use PY3 identifiers in favour of PY2 in pywikibot.page ......................................................................
[PY3] Use PY3 identifiers in favour of PY2 in pywikibot.page
- Do not rename Python 3 html.entities to the corresponding Python 2 identifier htmlentitydefs. Use the htmlentitydefs dict directly instead - use htmlentitydefs.get() instead of the current implementation
Change-Id: Ib1f3ceaa8767ee84e223b6e402bfde687d801c97 --- M pywikibot/page/__init__.py 1 file changed, 3 insertions(+), 7 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index 9085f15..acf6a99 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -57,7 +57,7 @@ from pywikibot.tools import is_IP
if not PY2: - from html import entities as htmlentitydefs + from html.entities import name2codepoint from urllib.parse import quote_from_bytes, unquote_to_bytes else: if __debug__ and not PY2: @@ -65,7 +65,7 @@
chr = unichr
- import htmlentitydefs + from htmlentitydefs import name2codepoint from urllib import quote as quote_from_bytes, unquote as unquote_to_bytes
@@ -6842,11 +6842,7 @@ unicode_codepoint = int(match.group('hex'), 16) elif match.group('name'): name = match.group('name') - if name in htmlentitydefs.name2codepoint: - # We found a known HTML entity. - unicode_codepoint = htmlentitydefs.name2codepoint[name] - else: - unicode_codepoint = False + unicode_codepoint = name2codepoint.get(name, False)
unicode_codepoint = _ILLEGAL_HTML_ENTITIES_MAPPING.get( unicode_codepoint, unicode_codepoint)