From bbf9d4608bb0358e50f2e210d39c5fb787078f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 4 Mar 2016 08:56:30 +0100 Subject: [PATCH] fields: fix unhtmled_label to return a byte string (#10193) --- tests/test_fields.py | 2 +- wcs/fields.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_fields.py b/tests/test_fields.py index 018a4cd..366a0bf 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -144,7 +144,7 @@ def test_comment(): assert field.unhtmled_label == 'Foobar' field = fields.CommentField(label='

Foobaré

') - assert field.unhtmled_label == u'Foobaré' + assert field.unhtmled_label == 'Foobaré' def test_map(): assert fields.MapField().get_json_value('42.2;10.2') == {'lat': 42.2, 'lon': 10.2} diff --git a/wcs/fields.py b/wcs/fields.py index 73ce1d1..41d4c6f 100644 --- a/wcs/fields.py +++ b/wcs/fields.py @@ -158,8 +158,9 @@ class Field(object): @property def unhtmled_label(self): + charset = get_publisher().site_charset return HTMLParser().unescape(unicode( - re.sub('<.*?>', ' ', self.label), get_publisher().site_charset)).strip() + re.sub('<.*?>', ' ', self.label), charset)).strip().encode(charset) def get_admin_attributes(self): return ['label', 'type'] -- 2.7.0