# HG changeset patch # User Julien Cristau # Date 1444679330 -7200 # Node ID 2ef74a6e678526f65ccec7627849e46683cd3a76 # Parent e63fb79b32e0823a3b03bab2e88c1183737ef08c [web] unicode → six.text_type diff -r e63fb79b32e0 -r 2ef74a6e6785 web/test/unittest_form.py --- a/web/test/unittest_form.py Mon Oct 12 20:43:50 2015 +0200 +++ b/web/test/unittest_form.py Mon Oct 12 21:48:50 2015 +0200 @@ -21,6 +21,8 @@ from xml.etree.ElementTree import fromstring from lxml import html +from six import text_type + from logilab.common.testlib import unittest_main from cubicweb import Binary, ValidationError @@ -65,19 +67,19 @@ t = req.create_entity('Tag', name=u'x') form1 = self.vreg['forms'].select('edition', req, entity=t) choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] - self.assertIn(unicode(b.eid), choices) + self.assertIn(text_type(b.eid), choices) form2 = self.vreg['forms'].select('edition', req, entity=b) choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] - self.assertIn(unicode(t.eid), choices) + self.assertIn(text_type(t.eid), choices) b.cw_clear_all_caches() t.cw_clear_all_caches() req.cnx.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry') choices = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)] - self.assertIn(unicode(b.eid), choices) + self.assertIn(text_type(b.eid), choices) choices = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)] - self.assertIn(unicode(t.eid), choices) + self.assertIn(text_type(t.eid), choices) def test_form_field_choices_new_entity(self): with self.admin_access.web_request() as req: diff -r e63fb79b32e0 -r 2ef74a6e6785 web/views/forms.py --- a/web/views/forms.py Mon Oct 12 20:43:50 2015 +0200 +++ b/web/views/forms.py Mon Oct 12 21:48:50 2015 +0200 @@ -50,6 +50,8 @@ import time import inspect +from six import text_type + from logilab.common import dictattr, tempattr from logilab.common.decorators import iclassmethod, cached from logilab.common.textutils import splitstrip @@ -287,7 +289,7 @@ except ProcessFormError as exc: errors.append((field, exc)) if errors: - errors = dict((f.role_name(), unicode(ex)) for f, ex in errors) + errors = dict((f.role_name(), text_type(ex)) for f, ex in errors) raise ValidationError(None, errors) return processed