summaryrefslogtreecommitdiff
path: root/django
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
parenta80903b7114c984b5087597e8c34750e7bb44f51 (diff)
Fixed #27857 -- Dropped support for Python 3.4.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/expressions.py6
-rw-r--r--django/http/cookie.py17
-rw-r--r--django/test/html.py9
-rw-r--r--django/urls/converters.py5
-rw-r--r--django/urls/resolvers.py4
-rw-r--r--django/utils/html.py18
-rw-r--r--django/utils/html_parser.py17
7 files changed, 15 insertions, 61 deletions
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
index 49ca801924..def866efbd 100644
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -150,12 +150,6 @@ class BaseExpression:
if output_field is not None:
self.output_field = output_field
- def __getstate__(self):
- # This method required only for Python 3.4.
- state = self.__dict__.copy()
- state.pop('convert_value', None)
- return state
-
def get_db_converters(self, connection):
return (
[]
diff --git a/django/http/cookie.py b/django/http/cookie.py
index 52dff786c4..b94d2b0386 100644
--- a/django/http/cookie.py
+++ b/django/http/cookie.py
@@ -1,20 +1,7 @@
-import sys
from http import cookies
-# Cookie pickling bug is fixed in Python 3.4.3+
-# http://bugs.python.org/issue22775
-if sys.version_info >= (3, 4, 3):
- SimpleCookie = cookies.SimpleCookie
-else:
- Morsel = cookies.Morsel
-
- class SimpleCookie(cookies.SimpleCookie):
- def __setitem__(self, key, value):
- if isinstance(value, Morsel):
- # allow assignment of constructed Morsels (e.g. for pickling)
- dict.__setitem__(self, key, value)
- else:
- super().__setitem__(key, value)
+# For backwards compatibility in Django 2.1.
+SimpleCookie = cookies.SimpleCookie
def parse_cookie(cookie):
diff --git a/django/test/html.py b/django/test/html.py
index 726beb6e93..b5ec00b16f 100644
--- a/django/test/html.py
+++ b/django/test/html.py
@@ -1,8 +1,7 @@
"""Compare two HTML documents."""
import re
-
-from django.utils.html_parser import HTMLParseError, HTMLParser
+from html.parser import HTMLParser
WHITESPACE = re.compile(r'\s+')
@@ -138,6 +137,10 @@ class RootElement(Element):
return ''.join(str(c) for c in self.children)
+class HTMLParseError(Exception):
+ pass
+
+
class Parser(HTMLParser):
SELF_CLOSING_TAGS = (
'br', 'hr', 'input', 'img', 'meta', 'spacer', 'link', 'frame', 'base',
@@ -145,7 +148,7 @@ class Parser(HTMLParser):
)
def __init__(self):
- HTMLParser.__init__(self)
+ HTMLParser.__init__(self, convert_charrefs=False)
self.root = RootElement()
self.open_tags = []
self.element_positions = {}
diff --git a/django/urls/converters.py b/django/urls/converters.py
index eb2a61971e..cc22f33df4 100644
--- a/django/urls/converters.py
+++ b/django/urls/converters.py
@@ -60,10 +60,7 @@ def register_converter(converter, type_name):
@lru_cache.lru_cache(maxsize=None)
def get_converters():
- converters = {}
- converters.update(DEFAULT_CONVERTERS)
- converters.update(REGISTERED_CONVERTERS)
- return converters
+ return {**DEFAULT_CONVERTERS, **REGISTERED_CONVERTERS}
def get_converter(raw_converter):
diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py
index 4cd25ff075..b214264445 100644
--- a/django/urls/resolvers.py
+++ b/django/urls/resolvers.py
@@ -343,9 +343,7 @@ class URLPattern:
'path.to.ClassBasedView').
"""
callback = self.callback
- # Python 3.5 collapses nested partials, so can change "while" to "if"
- # when it's the minimum supported version.
- while isinstance(callback, functools.partial):
+ if isinstance(callback, functools.partial):
callback = callback.func
if not hasattr(callback, '__name__'):
return callback.__module__ + "." + callback.__class__.__name__
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)