Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Replaced some smart_xxx by force_xxx equivalent

smart_str/smart_text should only be used when a potential lazy
string should be preserved in the result of the function call.
  • Loading branch information...
commit ae88e73fa630694a152b54df68d53ce535312e45 1 parent 36df198
Claude Paroz authored August 29, 2012
12  django/contrib/databrowse/datastructures.py
@@ -7,7 +7,7 @@
7 7
 from django.db import models
8 8
 from django.utils import formats
9 9
 from django.utils.text import capfirst
10  
-from django.utils.encoding import smart_text, smart_str, iri_to_uri
  10
+from django.utils.encoding import smart_text, force_str, iri_to_uri
11 11
 from django.db.models.query import QuerySet
12 12
 from django.utils.encoding import python_2_unicode_compatible
13 13
 
@@ -23,7 +23,7 @@ def __init__(self, site, model):
23 23
         self.verbose_name_plural = model._meta.verbose_name_plural
24 24
 
25 25
     def __repr__(self):
26  
-        return smart_str('<EasyModel for %s>' % self.model._meta.object_name)
  26
+        return force_str('<EasyModel for %s>' % self.model._meta.object_name)
27 27
 
28 28
     def model_databrowse(self):
29 29
         "Returns the ModelDatabrowse class for this model."
@@ -62,7 +62,7 @@ def __init__(self, easy_model, field):
62 62
         self.model, self.field = easy_model, field
63 63
 
64 64
     def __repr__(self):
65  
-        return smart_str('<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
  65
+        return force_str('<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
66 66
 
67 67
     def choices(self):
68 68
         for value, label in self.field.choices:
@@ -80,7 +80,7 @@ def __init__(self, easy_model, field, value, label):
80 80
         self.value, self.label = value, label
81 81
 
82 82
     def __repr__(self):
83  
-        return smart_str('<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
  83
+        return force_str('<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
84 84
 
85 85
     def url(self):
86 86
         return '%s%s/%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.field.name, iri_to_uri(self.value))
@@ -91,7 +91,7 @@ def __init__(self, easy_model, instance):
91 91
         self.model, self.instance = easy_model, instance
92 92
 
93 93
     def __repr__(self):
94  
-        return smart_str('<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val()))
  94
+        return force_str('<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val()))
95 95
 
96 96
     def __str__(self):
97 97
         val = smart_text(self.instance)
@@ -135,7 +135,7 @@ def __init__(self, easy_model, instance, field):
135 135
         self.raw_value = getattr(instance.instance, field.name)
136 136
 
137 137
     def __repr__(self):
138  
-        return smart_str('<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
  138
+        return force_str('<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
139 139
 
140 140
     def values(self):
141 141
         """
4  django/core/cache/backends/memcached.py
@@ -6,7 +6,7 @@
6 6
 from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
7 7
 
8 8
 from django.utils import six
9  
-from django.utils.encoding import smart_str
  9
+from django.utils.encoding import force_str
10 10
 
11 11
 class BaseMemcachedCache(BaseCache):
12 12
     def __init__(self, server, params, library, value_not_found_exception):
@@ -53,7 +53,7 @@ def _get_memcache_timeout(self, timeout):
53 53
 
54 54
     def make_key(self, key, version=None):
55 55
         # Python 2 memcache requires the key to be a byte string.
56  
-        return smart_str(super(BaseMemcachedCache, self).make_key(key, version))
  56
+        return force_str(super(BaseMemcachedCache, self).make_key(key, version))
57 57
 
58 58
     def add(self, key, value, timeout=0, version=None):
59 59
         key = self.make_key(key, version=version)
4  django/core/files/uploadedfile.py
@@ -8,7 +8,7 @@
8 8
 from django.conf import settings
9 9
 from django.core.files.base import File
10 10
 from django.core.files import temp as tempfile
11  
-from django.utils.encoding import smart_str
  11
+from django.utils.encoding import force_str
12 12
 
13 13
 __all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile',
14 14
            'SimpleUploadedFile')
@@ -30,7 +30,7 @@ def __init__(self, file=None, name=None, content_type=None, size=None, charset=N
30 30
         self.charset = charset
31 31
 
32 32
     def __repr__(self):
33  
-        return smart_str("<%s: %s (%s)>" % (
  33
+        return force_str("<%s: %s (%s)>" % (
34 34
             self.__class__.__name__, self.name, self.content_type))
35 35
 
36 36
     def _get_name(self):
4  django/core/handlers/wsgi.py
@@ -9,7 +9,7 @@
9 9
 from django.core.handlers import base
10 10
 from django.core.urlresolvers import set_script_prefix
11 11
 from django.utils import datastructures
12  
-from django.utils.encoding import force_text, smart_str, iri_to_uri
  12
+from django.utils.encoding import force_str, force_text, iri_to_uri
13 13
 from django.utils.log import getLogger
14 14
 
15 15
 logger = getLogger('django.request')
@@ -246,5 +246,5 @@ def __call__(self, environ, start_response):
246 246
         response_headers = [(str(k), str(v)) for k, v in response.items()]
247 247
         for c in response.cookies.values():
248 248
             response_headers.append((str('Set-Cookie'), str(c.output(header=''))))
249  
-        start_response(smart_str(status), response_headers)
  249
+        start_response(force_str(status), response_headers)
250 250
         return response
4  django/core/management/base.py
@@ -12,7 +12,7 @@
12 12
 import django
13 13
 from django.core.exceptions import ImproperlyConfigured
14 14
 from django.core.management.color import color_style
15  
-from django.utils.encoding import smart_str
  15
+from django.utils.encoding import force_str
16 16
 from django.utils.six import StringIO
17 17
 
18 18
 
@@ -65,7 +65,7 @@ def write(self, msg, style_func=None, ending=None):
65 65
             msg += ending
66 66
         style_func = [f for f in (style_func, self.style_func, lambda x:x)
67 67
                       if f is not None][0]
68  
-        self._out.write(smart_str(style_func(msg)))
  68
+        self._out.write(force_str(style_func(msg)))
69 69
 
70 70
 
71 71
 class BaseCommand(object):
4  django/core/management/validation.py
... ...
@@ -1,7 +1,7 @@
1 1
 import sys
2 2
 
3 3
 from django.core.management.color import color_style
4  
-from django.utils.encoding import smart_str
  4
+from django.utils.encoding import force_str
5 5
 from django.utils.itercompat import is_iterable
6 6
 from django.utils import six
7 7
 
@@ -13,7 +13,7 @@ def __init__(self, outfile=sys.stdout):
13 13
 
14 14
     def add(self, context, error):
15 15
         self.errors.append((context, error))
16  
-        self.outfile.write(self.style.ERROR(smart_str("%s: %s\n" % (context, error))))
  16
+        self.outfile.write(self.style.ERROR(force_str("%s: %s\n" % (context, error))))
17 17
 
18 18
 def get_validation_errors(outfile, app=None):
19 19
     """
6  django/core/urlresolvers.py
@@ -14,7 +14,7 @@
14 14
 from django.http import Http404
15 15
 from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
16 16
 from django.utils.datastructures import MultiValueDict
17  
-from django.utils.encoding import iri_to_uri, force_text, smart_str
  17
+from django.utils.encoding import force_str, force_text, iri_to_uri
18 18
 from django.utils.functional import memoize, lazy
19 19
 from django.utils.importlib import import_module
20 20
 from django.utils.module_loading import module_has_submodule
@@ -195,7 +195,7 @@ def __init__(self, regex, callback, default_args=None, name=None):
195 195
         self.name = name
196 196
 
197 197
     def __repr__(self):
198  
-        return smart_str('<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern))
  198
+        return force_str('<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern))
199 199
 
200 200
     def add_prefix(self, prefix):
201 201
         """
@@ -245,7 +245,7 @@ def __init__(self, regex, urlconf_name, default_kwargs=None, app_name=None, name
245 245
         self._app_dict = {}
246 246
 
247 247
     def __repr__(self):
248  
-        return smart_str('<%s %s (%s:%s) %s>' % (
  248
+        return force_str('<%s %s (%s:%s) %s>' % (
249 249
             self.__class__.__name__, self.urlconf_name, self.app_name,
250 250
             self.namespace, self.regex.pattern))
251 251
 
6  django/core/validators.py
@@ -8,7 +8,7 @@
8 8
 
9 9
 from django.core.exceptions import ValidationError
10 10
 from django.utils.translation import ugettext_lazy as _
11  
-from django.utils.encoding import smart_text
  11
+from django.utils.encoding import force_text
12 12
 from django.utils.ipv6 import is_valid_ipv6_address
13 13
 from django.utils import six
14 14
 
@@ -36,7 +36,7 @@ def __call__(self, value):
36 36
         """
37 37
         Validates that the input matches the regular expression.
38 38
         """
39  
-        if not self.regex.search(smart_text(value)):
  39
+        if not self.regex.search(force_text(value)):
40 40
             raise ValidationError(self.message, code=self.code)
41 41
 
42 42
 class URLValidator(RegexValidator):
@@ -55,7 +55,7 @@ def __call__(self, value):
55 55
         except ValidationError as e:
56 56
             # Trivial case failed. Try for possible IDN domain
57 57
             if value:
58  
-                value = smart_text(value)
  58
+                value = force_text(value)
59 59
                 scheme, netloc, path, query, fragment = urlsplit(value)
60 60
                 try:
61 61
                     netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
8  django/db/backends/__init__.py
@@ -609,7 +609,7 @@ def last_executed_query(self, cursor, sql, params):
609 609
         exists for database backends to provide a better implementation
610 610
         according to their own quoting schemes.
611 611
         """
612  
-        from django.utils.encoding import smart_text, force_text
  612
+        from django.utils.encoding import force_text
613 613
 
614 614
         # Convert params to contain Unicode values.
615 615
         to_unicode = lambda s: force_text(s, strings_only=True, errors='replace')
@@ -618,7 +618,7 @@ def last_executed_query(self, cursor, sql, params):
618 618
         else:
619 619
             u_params = dict([(to_unicode(k), to_unicode(v)) for k, v in params.items()])
620 620
 
621  
-        return smart_text(sql) % u_params
  621
+        return force_text(sql) % u_params
622 622
 
623 623
     def last_insert_id(self, cursor, table_name, pk_name):
624 624
         """
@@ -802,8 +802,8 @@ def tablespace_sql(self, tablespace, inline=False):
802 802
 
803 803
     def prep_for_like_query(self, x):
804 804
         """Prepares a value for use in a LIKE query."""
805  
-        from django.utils.encoding import smart_text
806  
-        return smart_text(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_")
  805
+        from django.utils.encoding import force_text
  806
+        return force_text(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_")
807 807
 
808 808
     # Same as prep_for_like_query(), but called for "iexact" matches, which
809 809
     # need not necessarily be implemented using "LIKE" in the backend.
4  django/db/models/base.py
@@ -23,7 +23,7 @@
23 23
 from django.db.models.loading import register_models, get_model
24 24
 from django.utils.translation import ugettext_lazy as _
25 25
 from django.utils.functional import curry
26  
-from django.utils.encoding import smart_str, force_text
  26
+from django.utils.encoding import force_str, force_text
27 27
 from django.utils import six
28 28
 from django.utils.text import get_text_list, capfirst
29 29
 
@@ -404,7 +404,7 @@ def __repr__(self):
404 404
             u = six.text_type(self)
405 405
         except (UnicodeEncodeError, UnicodeDecodeError):
406 406
             u = '[Bad Unicode data]'
407  
-        return smart_str('<%s: %s>' % (self.__class__.__name__, u))
  407
+        return force_str('<%s: %s>' % (self.__class__.__name__, u))
408 408
 
409 409
     def __str__(self):
410 410
         if not six.PY3 and hasattr(self, '__unicode__'):
4  django/db/models/fields/files.py
@@ -8,7 +8,7 @@
8 8
 from django.core.files.storage import default_storage
9 9
 from django.core.files.images import ImageFile
10 10
 from django.db.models import signals
11  
-from django.utils.encoding import force_text, smart_str
  11
+from django.utils.encoding import force_str, force_text
12 12
 from django.utils import six
13 13
 from django.utils.translation import ugettext_lazy as _
14 14
 
@@ -280,7 +280,7 @@ def contribute_to_class(self, cls, name):
280 280
         setattr(cls, self.name, self.descriptor_class(self))
281 281
 
282 282
     def get_directory_name(self):
283  
-        return os.path.normpath(force_text(datetime.datetime.now().strftime(smart_str(self.upload_to))))
  283
+        return os.path.normpath(force_text(datetime.datetime.now().strftime(force_str(self.upload_to))))
284 284
 
285 285
     def get_filename(self, filename):
286 286
         return os.path.normpath(self.storage.get_valid_name(os.path.basename(filename)))
8  django/http/__init__.py
@@ -61,14 +61,14 @@ def value_encode(self, val):
61 61
         if not _cookie_allows_colon_in_names:
62 62
             def load(self, rawdata):
63 63
                 self.bad_cookies = set()
64  
-                super(SimpleCookie, self).load(smart_str(rawdata))
  64
+                super(SimpleCookie, self).load(force_str(rawdata))
65 65
                 for key in self.bad_cookies:
66 66
                     del self[key]
67 67
 
68 68
             # override private __set() method:
69 69
             # (needed for using our Morsel, and for laxness with CookieError
70 70
             def _BaseCookie__set(self, key, real_value, coded_value):
71  
-                key = smart_str(key)
  71
+                key = force_str(key)
72 72
                 try:
73 73
                     M = self.get(key, Morsel())
74 74
                     M.set(key, real_value, coded_value)
@@ -85,7 +85,7 @@ def _BaseCookie__set(self, key, real_value, coded_value):
85 85
 from django.http.multipartparser import MultiPartParser
86 86
 from django.http.utils import *
87 87
 from django.utils.datastructures import MultiValueDict, ImmutableList
88  
-from django.utils.encoding import force_bytes, force_text, smart_str, iri_to_uri
  88
+from django.utils.encoding import force_bytes, force_str, force_text, iri_to_uri
89 89
 from django.utils.http import cookie_date
90 90
 from django.utils import six
91 91
 from django.utils import timezone
@@ -137,7 +137,7 @@ def build_request_repr(request, path_override=None, GET_override=None,
137 137
     except Exception:
138 138
         meta = '<could not parse>'
139 139
     path = path_override if path_override is not None else request.path
140  
-    return smart_str('<%s\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' %
  140
+    return force_str('<%s\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' %
141 141
                      (request.__class__.__name__,
142 142
                       path,
143 143
                       six.text_type(get),
6  django/template/base.py
@@ -11,7 +11,7 @@
11 11
 from django.utils.itercompat import is_iterable
12 12
 from django.utils.text import (smart_split, unescape_string_literal,
13 13
     get_text_list)
14  
-from django.utils.encoding import smart_text, force_text, smart_str
  14
+from django.utils.encoding import force_str, force_text
15 15
 from django.utils.translation import ugettext_lazy, pgettext_lazy
16 16
 from django.utils.safestring import (SafeData, EscapeData, mark_safe,
17 17
     mark_for_escaping)
@@ -116,7 +116,7 @@ class Template(object):
116 116
     def __init__(self, template_string, origin=None,
117 117
                  name='<Unknown Template>'):
118 118
         try:
119  
-            template_string = smart_text(template_string)
  119
+            template_string = force_text(template_string)
120 120
         except UnicodeDecodeError:
121 121
             raise TemplateEncodingError("Templates can only be constructed "
122 122
                                         "from unicode or UTF-8 strings.")
@@ -848,7 +848,7 @@ def __init__(self, s):
848 848
         self.s = s
849 849
 
850 850
     def __repr__(self):
851  
-        return "<Text Node: '%s'>" % smart_str(self.s[:25], 'ascii',
  851
+        return force_str("<Text Node: '%s'>" % self.s[:25], 'ascii',
852 852
                 errors='replace')
853 853
 
854 854
     def render(self, context):
10  django/utils/formats.py
@@ -4,7 +4,7 @@
4 4
 from django.conf import settings
5 5
 from django.utils import dateformat, numberformat, datetime_safe
6 6
 from django.utils.importlib import import_module
7  
-from django.utils.encoding import smart_str
  7
+from django.utils.encoding import force_str
8 8
 from django.utils.functional import lazy
9 9
 from django.utils.safestring import mark_safe
10 10
 from django.utils import six
@@ -66,7 +66,7 @@ def get_format(format_type, lang=None, use_l10n=None):
66 66
     If use_l10n is provided and is not None, that will force the value to
67 67
     be localized (or not), overriding the value of settings.USE_L10N.
68 68
     """
69  
-    format_type = smart_str(format_type)
  69
+    format_type = force_str(format_type)
70 70
     if use_l10n or (use_l10n is None and settings.USE_L10N):
71 71
         if lang is None:
72 72
             lang = get_language()
@@ -160,14 +160,14 @@ def localize_input(value, default=None):
160 160
         return number_format(value)
161 161
     elif isinstance(value, datetime.datetime):
162 162
         value = datetime_safe.new_datetime(value)
163  
-        format = smart_str(default or get_format('DATETIME_INPUT_FORMATS')[0])
  163
+        format = force_str(default or get_format('DATETIME_INPUT_FORMATS')[0])
164 164
         return value.strftime(format)
165 165
     elif isinstance(value, datetime.date):
166 166
         value = datetime_safe.new_date(value)
167  
-        format = smart_str(default or get_format('DATE_INPUT_FORMATS')[0])
  167
+        format = force_str(default or get_format('DATE_INPUT_FORMATS')[0])
168 168
         return value.strftime(format)
169 169
     elif isinstance(value, datetime.time):
170  
-        format = smart_str(default or get_format('TIME_INPUT_FORMATS')[0])
  170
+        format = force_str(default or get_format('TIME_INPUT_FORMATS')[0])
171 171
         return value.strftime(format)
172 172
     return value
173 173
 
14  django/utils/http.py
@@ -15,7 +15,7 @@
15 15
 from email.utils import formatdate
16 16
 
17 17
 from django.utils.datastructures import MultiValueDict
18  
-from django.utils.encoding import force_text, smart_str
  18
+from django.utils.encoding import force_str, force_text
19 19
 from django.utils.functional import allow_lazy
20 20
 from django.utils import six
21 21
 
@@ -39,7 +39,7 @@ def urlquote(url, safe='/'):
39 39
     can safely be used as part of an argument to a subsequent iri_to_uri() call
40 40
     without double-quoting occurring.
41 41
     """
42  
-    return force_text(urllib_parse.quote(smart_str(url), smart_str(safe)))
  42
+    return force_text(urllib_parse.quote(force_str(url), force_str(safe)))
43 43
 urlquote = allow_lazy(urlquote, six.text_type)
44 44
 
45 45
 def urlquote_plus(url, safe=''):
@@ -49,7 +49,7 @@ def urlquote_plus(url, safe=''):
49 49
     returned string can safely be used as part of an argument to a subsequent
50 50
     iri_to_uri() call without double-quoting occurring.
51 51
     """
52  
-    return force_text(urllib_parse.quote_plus(smart_str(url), smart_str(safe)))
  52
+    return force_text(urllib_parse.quote_plus(force_str(url), force_str(safe)))
53 53
 urlquote_plus = allow_lazy(urlquote_plus, six.text_type)
54 54
 
55 55
 def urlunquote(quoted_url):
@@ -57,7 +57,7 @@ def urlunquote(quoted_url):
57 57
     A wrapper for Python's urllib.unquote() function that can operate on
58 58
     the result of django.utils.http.urlquote().
59 59
     """
60  
-    return force_text(urllib_parse.unquote(smart_str(quoted_url)))
  60
+    return force_text(urllib_parse.unquote(force_str(quoted_url)))
61 61
 urlunquote = allow_lazy(urlunquote, six.text_type)
62 62
 
63 63
 def urlunquote_plus(quoted_url):
@@ -65,7 +65,7 @@ def urlunquote_plus(quoted_url):
65 65
     A wrapper for Python's urllib.unquote_plus() function that can operate on
66 66
     the result of django.utils.http.urlquote_plus().
67 67
     """
68  
-    return force_text(urllib_parse.unquote_plus(smart_str(quoted_url)))
  68
+    return force_text(urllib_parse.unquote_plus(force_str(quoted_url)))
69 69
 urlunquote_plus = allow_lazy(urlunquote_plus, six.text_type)
70 70
 
71 71
 def urlencode(query, doseq=0):
@@ -79,8 +79,8 @@ def urlencode(query, doseq=0):
79 79
     elif hasattr(query, 'items'):
80 80
         query = query.items()
81 81
     return urllib_parse.urlencode(
82  
-        [(smart_str(k),
83  
-         [smart_str(i) for i in v] if isinstance(v, (list,tuple)) else smart_str(v))
  82
+        [(force_str(k),
  83
+         [force_str(i) for i in v] if isinstance(v, (list,tuple)) else force_str(v))
84 84
             for k, v in query],
85 85
         doseq)
86 86
 
8  django/utils/translation/trans_real.py
@@ -9,7 +9,7 @@
9 9
 from threading import local
10 10
 
11 11
 from django.utils.importlib import import_module
12  
-from django.utils.encoding import smart_str, smart_text
  12
+from django.utils.encoding import force_str, force_text
13 13
 from django.utils.safestring import mark_safe, SafeData
14 14
 from django.utils import six
15 15
 from django.utils.six import StringIO
@@ -454,7 +454,7 @@ def templatize(src, origin=None):
454 454
     from django.conf import settings
455 455
     from django.template import (Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK,
456 456
             TOKEN_COMMENT, TRANSLATOR_COMMENT_MARK)
457  
-    src = smart_text(src, settings.FILE_CHARSET)
  457
+    src = force_text(src, settings.FILE_CHARSET)
458 458
     out = StringIO()
459 459
     message_context = None
460 460
     intrans = False
@@ -469,7 +469,7 @@ def templatize(src, origin=None):
469 469
                 content = ''.join(comment)
470 470
                 translators_comment_start = None
471 471
                 for lineno, line in enumerate(content.splitlines(True)):
472  
-                    if line.lstrip().startswith(smart_text(TRANSLATOR_COMMENT_MARK)):
  472
+                    if line.lstrip().startswith(TRANSLATOR_COMMENT_MARK):
473 473
                         translators_comment_start = lineno
474 474
                 for lineno, line in enumerate(content.splitlines(True)):
475 475
                     if translators_comment_start is not None and lineno >= translators_comment_start:
@@ -584,7 +584,7 @@ def templatize(src, origin=None):
584 584
                 out.write(' # %s' % t.contents)
585 585
             else:
586 586
                 out.write(blankout(t.contents, 'X'))
587  
-    return smart_str(out.getvalue())
  587
+    return force_str(out.getvalue())
588 588
 
589 589
 def parse_accept_lang_header(lang_string):
590 590
     """
6  django/utils/tzinfo.py
@@ -5,7 +5,7 @@
5 5
 import time
6 6
 from datetime import timedelta, tzinfo
7 7
 
8  
-from django.utils.encoding import smart_text, smart_str, DEFAULT_LOCALE_ENCODING
  8
+from django.utils.encoding import force_str, force_text, DEFAULT_LOCALE_ENCODING
9 9
 
10 10
 # Python's doc say: "A tzinfo subclass must have an __init__() method that can
11 11
 # be called with no arguments". FixedOffset and LocalTimezone don't honor this
@@ -53,7 +53,7 @@ def __init__(self, dt):
53 53
         self._tzname = self.tzname(dt)
54 54
 
55 55
     def __repr__(self):
56  
-        return smart_str(self._tzname)
  56
+        return force_str(self._tzname)
57 57
 
58 58
     def __getinitargs__(self):
59 59
         return self.__dt,
@@ -72,7 +72,7 @@ def dst(self, dt):
72 72
 
73 73
     def tzname(self, dt):
74 74
         try:
75  
-            return smart_text(time.tzname[self._isdst(dt)],
  75
+            return force_text(time.tzname[self._isdst(dt)],
76 76
                                  DEFAULT_LOCALE_ENCODING)
77 77
         except UnicodeDecodeError:
78 78
             return None

0 notes on commit ae88e73

Please sign in to comment.
Something went wrong with that request. Please try again.