summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-02-17 19:45:34 -0500
committerTim Graham <timograham@gmail.com>2017-09-25 17:11:03 -0400
commitcfff2af02be40106d4759cc6f8bfa476ce82421c (patch)
tree2680ff4040dd83d7b50ca2265e8268e362142476 /django/utils
parenta80903b7114c984b5087597e8c34750e7bb44f51 (diff)
Fixed #27857 -- Dropped support for Python 3.4.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/html.py18
-rw-r--r--django/utils/html_parser.py17
2 files changed, 5 insertions, 30 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index 9f4f58c7a1..e365cd41f6 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -1,6 +1,7 @@
"""HTML utilities suitable for global use."""
import re
+from html.parser import HTMLParser
from urllib.parse import (
parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit,
)
@@ -11,8 +12,6 @@ from django.utils.http import RFC3986_GENDELIMS, RFC3986_SUBDELIMS
from django.utils.safestring import SafeData, SafeText, mark_safe
from django.utils.text import normalize_newlines
-from .html_parser import HTMLParseError, HTMLParser
-
# Configuration for urlize() function.
TRAILING_PUNCTUATION_RE = re.compile(
'^' # Beginning of word
@@ -132,7 +131,7 @@ def linebreaks(value, autoescape=False):
class MLStripper(HTMLParser):
def __init__(self):
- HTMLParser.__init__(self)
+ HTMLParser.__init__(self, convert_charrefs=False)
self.reset()
self.fed = []
@@ -154,16 +153,9 @@ def _strip_once(value):
Internal tag stripping utility used by strip_tags.
"""
s = MLStripper()
- try:
- s.feed(value)
- except HTMLParseError:
- return value
- try:
- s.close()
- except HTMLParseError:
- return s.get_data() + s.rawdata
- else:
- return s.get_data()
+ s.feed(value)
+ s.close()
+ return s.get_data()
@keep_lazy_text
diff --git a/django/utils/html_parser.py b/django/utils/html_parser.py
deleted file mode 100644
index 6b46ddc368..0000000000
--- a/django/utils/html_parser.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import html.parser
-
-try:
- HTMLParseError = html.parser.HTMLParseError
-except AttributeError:
- # create a dummy class for Python 3.5+ where it's been removed
- class HTMLParseError(Exception):
- pass
-
-
-class HTMLParser(html.parser.HTMLParser):
- """Explicitly set convert_charrefs to be False.
-
- This silences a deprecation warning on Python 3.4.
- """
- def __init__(self, convert_charrefs=False, **kwargs):
- html.parser.HTMLParser.__init__(self, convert_charrefs=convert_charrefs, **kwargs)