[py3k] unicode → six.text_type
authorRémi Cardona <remi.cardona@logilab.fr>
Wed, 16 Sep 2015 17:28:06 +0200
changeset 10672 f6f425a54a8d
parent 10671 e08102f45237
child 10673 9924fd69bcba
[py3k] unicode → six.text_type
req.py
web/facet.py
web/request.py
--- a/req.py	Tue Oct 13 16:57:09 2015 +0200
+++ b/req.py	Wed Sep 16 17:28:06 2015 +0200
@@ -22,6 +22,7 @@
 from warnings import warn
 from datetime import time, datetime, timedelta
 
+from six import text_type
 from six.moves.urllib.parse import parse_qs, parse_qsl, quote as urlquote, unquote as urlunquote, urlsplit, urlunsplit
 
 from logilab.common.decorators import cached
@@ -72,7 +73,7 @@
         # connection
         self.user = None
         self.local_perm_cache = {}
-        self._ = unicode
+        self._ = text_type
 
     def _set_user(self, orig_user):
         """set the user for this req_session_base
--- a/web/facet.py	Tue Oct 13 16:57:09 2015 +0200
+++ b/web/facet.py	Wed Sep 16 17:28:06 2015 +0200
@@ -57,7 +57,7 @@
 from copy import deepcopy
 from datetime import datetime, timedelta
 
-from six import string_types
+from six import text_type, string_types
 
 from logilab.mtconverter import xml_escape
 from logilab.common.graph import has_path
@@ -721,14 +721,14 @@
 
     def rset_vocabulary(self, rset):
         if self.i18nable:
-            _ = self._cw._
+            tr = self._cw._
         else:
-            _ = unicode
+            tr = text_type
         if self.rql_sort:
-            values = [(_(label), eid) for eid, label in rset]
+            values = [(tr(label), eid) for eid, label in rset]
         else:
             if self.label_vid is None:
-                values = [(_(label), eid) for eid, label in rset]
+                values = [(tr(label), eid) for eid, label in rset]
             else:
                 values = [(entity.view(self.label_vid), entity.eid)
                           for entity in rset.entities()]
@@ -918,12 +918,12 @@
 
     def rset_vocabulary(self, rset):
         if self.i18nable:
-            _ = self._cw._
+            tr = self._cw._
         else:
-            _ = unicode
+            tr = text_type
         if self.rql_sort:
-            return [(_(value), value) for value, in rset]
-        values = [(_(value), value) for value, in rset]
+            return [(tr(value), value) for value, in rset]
+        values = [(tr(value), value) for value, in rset]
         return sorted(values, reverse=not self.sortasc)
 
 
--- a/web/request.py	Tue Oct 13 16:57:09 2015 +0200
+++ b/web/request.py	Wed Sep 16 17:28:06 2015 +0200
@@ -28,7 +28,7 @@
 from warnings import warn
 from io import BytesIO
 
-from six import string_types
+from six import text_type, string_types
 from six.moves import http_client
 from six.moves.urllib.parse import urlsplit, quote as urlquote
 from six.moves.http_cookies import SimpleCookie
@@ -1024,8 +1024,8 @@
             self.set_language(lang)
         except KeyError:
             # this occurs usually during test execution
-            self._ = self.__ = unicode
-            self.pgettext = lambda x, y: unicode(y)
+            self._ = self.__ = text_type
+            self.pgettext = lambda x, y: text_type(y)
 
     entity_metas = _cnx_func('entity_metas')
     source_defs = _cnx_func('source_defs')