changeset 5417:c749d6795bc2

Python 3 preparation: unichr.
author Joseph Myers <jsm@polyomino.org.uk>
date Wed, 25 Jul 2018 09:07:03 +0000
parents 56c9bcdea47f
children 55f09ca366c4
files roundup/anypy/strings.py roundup/cgi/client.py roundup/dehtml.py
diffstat 3 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/anypy/strings.py	Wed Jul 25 09:05:58 2018 +0000
+++ b/roundup/anypy/strings.py	Wed Jul 25 09:07:03 2018 +0000
@@ -73,3 +73,10 @@
         return isinstance(s, str)
     else:
         return isinstance(s, str) or isinstance(s, unicode)
+
+def uchr(c):
+    """Return the Unicode string containing the given character."""
+    if _py3:
+        return chr(c)
+    else:
+        return unichr(c)
--- a/roundup/cgi/client.py	Wed Jul 25 09:05:58 2018 +0000
+++ b/roundup/cgi/client.py	Wed Jul 25 09:07:03 2018 +0000
@@ -49,6 +49,8 @@
 from email.MIMEMultipart import MIMEMultipart
 import roundup.anypy.email_
 
+from roundup.anypy.strings import uchr
+
 def initialiseSecurity(security):
     '''Create some Permissions and Roles on the security object
 
@@ -778,7 +780,7 @@
                     uc = int(num[1:], 16)
                 else:
                     uc = int(num)
-                return unichr(uc)
+                return uchr(uc)
 
             for field_name in self.form:
                 field = self.form[field_name]
--- a/roundup/dehtml.py	Wed Jul 25 09:05:58 2018 +0000
+++ b/roundup/dehtml.py	Wed Jul 25 09:07:03 2018 +0000
@@ -1,6 +1,6 @@
 
 from __future__ import print_function
-from roundup.anypy.strings import u2s
+from roundup.anypy.strings import u2s, uchr
 class dehtml:
     def __init__(self, converter):
         if converter == "none":
@@ -70,7 +70,7 @@
                 def handle_entityref(self, name):
                     if self._skip_data:
                         return
-                    c = unichr(name2codepoint[name])
+                    c = uchr(name2codepoint[name])
                     try:
                         self.text= self.text + c
                     except UnicodeEncodeError:

Roundup Issue Tracker: http://roundup-tracker.org/