From 5f3b00854bbc6fa6a03e04ab572a609eebcc1f72 Mon Sep 17 00:00:00 2001 From: Stefane Fermigier Date: Thu, 3 Aug 2017 20:22:46 +0200 Subject: [PATCH] Add __str__ to DateTimePattern (#515) Fixes #514 --- babel/dates.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.47.2