From: Stefane Fermigier Date: Thu, 3 Aug 2017 18:22:46 +0000 (+0200) Subject: Add __str__ to DateTimePattern (#515) X-Git-Tag: v2.5.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f3b00854bbc6fa6a03e04ab572a609eebcc1f72;p=thirdparty%2Fbabel.git Add __str__ to DateTimePattern (#515) Fixes #514 --- diff --git a/babel/dates.py b/babel/dates.py index c84ca486..75e53a1d 100644 --- a/babel/dates.py +++ b/babel/dates.py @@ -27,8 +27,7 @@ from bisect import bisect_right from babel.core import default_locale, get_global, Locale from babel.util import UTC, LOCALTZ -from babel._compat import string_types, integer_types, number_types - +from babel._compat import string_types, integer_types, number_types, PY2 # "If a given short metazone form is known NOT to be understood in a given # locale and the parent locale has this value such that it would normally @@ -1218,6 +1217,12 @@ class DateTimePattern(object): def __unicode__(self): return self.pattern + def __str__(self): + pat = self.pattern + if PY2: + pat = pat.encode('utf-8') + return pat + def __mod__(self, other): if type(other) is not DateTimeFormat: return NotImplemented