jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Python 3: Use chr instead of unichr in Python 3
......................................................................
[FIX] Python 3: Use chr instead of unichr in Python 3
The change in page.py is different than the normal change, because
Python 3 doesn't suffer from the problem that it might not support
charpoints above 2¹⁶.
Change-Id: Id49f6dd0aa81a8b915f20453dbb679fd840a9a80
---
M pywikibot/page.py
M scripts/featured.py
2 files changed, 8 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 39cb3ad..a9ca948 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4410,8 +4410,10 @@
except KeyError:
pass
if unicodeCodepoint and unicodeCodepoint not in ignore:
- # solve narrow Python build exception (UTF-16)
- if unicodeCodepoint > sys.maxunicode:
+ if sys.version_info[0] > 2:
+ result += chr(unicodeCodepoint)
+ elif 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)
else:
diff --git a/scripts/featured.py b/scripts/featured.py
index 6893f96..98cb0a7 100644
--- a/scripts/featured.py
+++ b/scripts/featured.py
@@ -64,11 +64,15 @@
import pickle
import re
+import sys
import pywikibot
from pywikibot import i18n, textlib
from pywikibot.pagegenerators import PreloadingGenerator
from pywikibot.config2 import LS # line separator
+if sys.version_info[0] > 2:
+ unichr = chr
+
def CAT(site, name, hide):
name = site.namespace(14) + ':' + name
--
To view, visit
https://gerrit.wikimedia.org/r/160804
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id49f6dd0aa81a8b915f20453dbb679fd840a9a80
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>