Skip to content

Commit 4beb2f9

Browse files
committed
Python 3 preparation: unichr.
1 parent 25186a0 commit 4beb2f9

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

roundup/anypy/strings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ def is_us(s):
7373
return isinstance(s, str)
7474
else:
7575
return isinstance(s, str) or isinstance(s, unicode)
76+
77+
def uchr(c):
78+
"""Return the Unicode string containing the given character."""
79+
if _py3:
80+
return chr(c)
81+
else:
82+
return unichr(c)

roundup/cgi/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
from email.MIMEMultipart import MIMEMultipart
5050
import roundup.anypy.email_
5151

52+
from roundup.anypy.strings import uchr
53+
5254
def initialiseSecurity(security):
5355
'''Create some Permissions and Roles on the security object
5456
@@ -778,7 +780,7 @@ def _decode_charref(matchobj):
778780
uc = int(num[1:], 16)
779781
else:
780782
uc = int(num)
781-
return unichr(uc)
783+
return uchr(uc)
782784

783785
for field_name in self.form:
784786
field = self.form[field_name]

roundup/dehtml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
from __future__ import print_function
3-
from roundup.anypy.strings import u2s
3+
from roundup.anypy.strings import u2s, uchr
44
class dehtml:
55
def __init__(self, converter):
66
if converter == "none":
@@ -70,7 +70,7 @@ def handle_endtag(self, tag):
7070
def handle_entityref(self, name):
7171
if self._skip_data:
7272
return
73-
c = unichr(name2codepoint[name])
73+
c = uchr(name2codepoint[name])
7474
try:
7575
self.text= self.text + c
7676
except UnicodeEncodeError:

0 commit comments

Comments
 (0)