diff options
| author | Claude Paroz <claude@2xlibre.net> | 2016-12-01 11:38:01 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-01-18 16:21:28 +0100 |
| commit | c716fe87821df00f9f03ecc761c914d1682591a2 (patch) | |
| tree | 0436706cdb190acbc76fb5fcf6d66f16e09fafa3 /django/utils/html.py | |
| parent | e63d98b7beb16d1410168a2315cbe04c43c9c80d (diff) | |
Refs #23919 -- Removed six.PY2/PY3 usage
Thanks Tim Graham for the review.
Diffstat (limited to 'django/utils/html.py')
| -rw-r--r-- | django/utils/html.py | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/django/utils/html.py b/django/utils/html.py index 384093a02f..36b5d53283 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -363,22 +363,12 @@ def html_safe(klass): "can't apply @html_safe to %s because it defines " "__html__()." % klass.__name__ ) - if six.PY2: - if '__unicode__' not in klass.__dict__: - raise ValueError( - "can't apply @html_safe to %s because it doesn't " - "define __unicode__()." % klass.__name__ - ) - klass_unicode = klass.__unicode__ - klass.__unicode__ = lambda self: mark_safe(klass_unicode(self)) - klass.__html__ = lambda self: unicode(self) # NOQA: unicode undefined on PY3 - else: - if '__str__' not in klass.__dict__: - raise ValueError( - "can't apply @html_safe to %s because it doesn't " - "define __str__()." % klass.__name__ - ) - klass_str = klass.__str__ - klass.__str__ = lambda self: mark_safe(klass_str(self)) - klass.__html__ = lambda self: str(self) + if '__str__' not in klass.__dict__: + raise ValueError( + "can't apply @html_safe to %s because it doesn't " + "define __str__()." % klass.__name__ + ) + klass_str = klass.__str__ + klass.__str__ = lambda self: mark_safe(klass_str(self)) + klass.__html__ = lambda self: str(self) return klass |
