Skip to content

Commit 77e166a

Browse files
committed
Fixed python3 support and added to unit tests.
1 parent dde1dff commit 77e166a

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

flask_babel/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
timezone = pytz.timezone
2929
UTC = pytz.UTC
3030

31-
from flask_babel._compat import string_types
31+
from flask_babel._compat import string_types, text_type
3232

3333

3434
class Babel(object):
@@ -512,9 +512,9 @@ def make_json_lazy_string(func, *args, **kwargs):
512512
from speaklater import _LazyString
513513

514514
class JsonLazyString(_LazyString):
515-
__slots__ = _LazyString.__slots__ + ('__html__',)
516515
def __html__(self):
517-
return unicode(self)
516+
return text_type(self)
517+
518518
return JsonLazyString(func, args, kwargs)
519519

520520
def lazy_gettext(string, **variables):

tests/tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ def test_lazy_gettext(self):
158158
yes = lazy_gettext(u'Yes')
159159
with app.test_request_context():
160160
assert text_type(yes) == 'Ja'
161+
assert yes.__html__() == 'Ja'
161162
app.config['BABEL_DEFAULT_LOCALE'] = 'en_US'
162163
with app.test_request_context():
163164
assert text_type(yes) == 'Yes'
165+
assert yes.__html__() == 'Yes'
164166

165167
def test_list_translations(self):
166168
app = flask.Flask(__name__)

0 commit comments

Comments
 (0)