Commits

Jason R. Coombs committed bc640d7

Improved unicode support and fixed TypeError storing Unicode channel names

  • Participants
  • Parent commits 8203510
  • Tags 2.0.3

Comments (0)

Files changed (3)

+2.0.3
+=====
+
+* Improved Unicode support. Fixes failing tests and errors lowering Unicode
+  channel names.
+
 2.0.2
 =====
 
+from __future__ import unicode_literals
+
 from . import strings
 
 # from jaraco.util.dictlib
 
     The dict maintains the original case:
     >>> d.keys()
-    ['A', '[This]']
+    [u'A', u'[This]']
 
     But the keys can be referenced with a different case
     >>> d['a']
-    'foo'
+    u'foo'
 
     >>> d['{this}']
-    'that'
+    u'that'
 
     >>> d['{THIS}']
-    'that'
+    u'that'
 
     >>> '{thiS]' in d
     True
 
     This should work for operations like delete and pop as well.
     >>> d.pop('A')
-    'foo'
+    u'foo'
     >>> del d['{This}']
     >>> len(d)
     0

File irc/strings.py

-from __future__ import absolute_import
+from __future__ import absolute_import, unicode_literals
 
 import re
 import string
     strings (RFC 1459).
 
     >>> IRCFoldedCase('Foo^').lower()
-    'foo~'
+    u'foo~'
     >>> IRCFoldedCase('[this]') == IRCFoldedCase('{THIS}')
     True
     """
-    translation = string.maketrans(
-        string.ascii_uppercase + r"[]\^",
-        string.ascii_lowercase + r"{}|~",
-    )
+    translation = dict(zip(
+        map(ord, string.ascii_uppercase + r"[]\^"),
+        map(ord, string.ascii_lowercase + r"{}|~"),
+    ))
 
     def lower(self):
         return self.translate(self.translation)