jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] page: Don't use lambda for narrow-unichr
......................................................................
[IMPROV] page: Don't use lambda for narrow-unichr
In 3d093f5393e8d13571b64631735fd740a5e89dff a fix was implemented for
unicode characters outside the support Unicode width. But the usage of
lambda isn't necessary.
Change-Id: I26525704c89a53b8e3cbcee3ab1549aa1830c934
---
M pywikibot/page.py
M tests/page_tests.py
2 files changed, 19 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 1eaf51a..f38dc5c 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4839,8 +4839,7 @@
if unicodeCodepoint and unicodeCodepoint not in ignore:
if unicodeCodepoint > sys.maxunicode:
# solve narrow Python 2 build exception (UTF-16)
- unicode_literal = lambda n: eval(r"u'\U%08x'" % n)
- result += unicode_literal(unicodeCodepoint)
+ result +=
eval(r"u'\U{:08x}'".format(unicodeCodepoint))
else:
result += chr(unicodeCodepoint)
else:
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 5153bab..bc77765 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -785,6 +785,24 @@
self.assertEqual(p1.protection(), {})
+class HtmlEntity(TestCase):
+
+ """Test that HTML entities are correctly decoded."""
+
+ net = False
+
+ def test_valid_entities(self):
+ """Test valid entities."""
+ self.assertEqual(pywikibot.page.html2unicode('A&O'),
'A&O')
+ self.assertEqual(pywikibot.page.html2unicode('py'),
'py')
+ self.assertEqual(pywikibot.page.html2unicode('𐀀'),
u'\U00010000')
+
+ @unittest.expectedFailure
+ def test_recursive_entities(self):
+ """Test recursive entities."""
+ self.assertEqual(pywikibot.page.html2unicode('A&O'),
'A&O')
+
+
if __name__ == '__main__':
try:
unittest.main()
--
To view, visit
https://gerrit.wikimedia.org/r/196124
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I26525704c89a53b8e3cbcee3ab1549aa1830c934
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>