summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/functional.py2
-rw-r--r--django/utils/glob.py33
-rw-r--r--django/utils/html_parser.py3
-rw-r--r--django/utils/module_loading.py7
4 files changed, 14 insertions, 31 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index bade67de46..c0d19093fc 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -251,7 +251,7 @@ class LazyObject(object):
self._setup()
return self._wrapped.__dict__
- # Python 3.3 will call __reduce__ when pickling; this method is needed
+ # Python 3 will call __reduce__ when pickling; this method is needed
# to serialize and deserialize correctly.
@classmethod
def __newobj__(cls, *args):
diff --git a/django/utils/glob.py b/django/utils/glob.py
index a3138b09dc..d3f9e08138 100644
--- a/django/utils/glob.py
+++ b/django/utils/glob.py
@@ -7,30 +7,15 @@ from django.utils import six
# backport of Python 3.4's glob.escape
-try:
+if six.PY3:
from glob import escape as glob_escape
-except ImportError:
+else:
_magic_check = re.compile('([*?[])')
- if six.PY3:
- _magic_check_bytes = re.compile(b'([*?[])')
-
- def glob_escape(pathname):
- """
- Escape all special characters.
- """
- drive, pathname = os.path.splitdrive(pathname)
- if isinstance(pathname, bytes):
- pathname = _magic_check_bytes.sub(br'[\1]', pathname)
- else:
- pathname = _magic_check.sub(r'[\1]', pathname)
- return drive + pathname
-
- else:
- def glob_escape(pathname):
- """
- Escape all special characters.
- """
- drive, pathname = os.path.splitdrive(pathname)
- pathname = _magic_check.sub(r'[\1]', pathname)
- return drive + pathname
+ def glob_escape(pathname):
+ """
+ Escape all special characters.
+ """
+ drive, pathname = os.path.splitdrive(pathname)
+ pathname = _magic_check.sub(r'[\1]', pathname)
+ return drive + pathname
diff --git a/django/utils/html_parser.py b/django/utils/html_parser.py
index e7f7c11571..a69f914921 100644
--- a/django/utils/html_parser.py
+++ b/django/utils/html_parser.py
@@ -1,6 +1,7 @@
import re
import sys
+from django.utils import six
from django.utils.six.moves import html_parser as _html_parser
current_version = sys.version_info
@@ -15,7 +16,7 @@ except AttributeError:
pass
if not use_workaround:
- if current_version >= (3, 4):
+ if six.PY3:
class HTMLParser(_html_parser.HTMLParser):
"""Explicitly set convert_charrefs to be False.
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py
index c42d208178..4a2c500321 100644
--- a/django/utils/module_loading.py
+++ b/django/utils/module_loading.py
@@ -63,11 +63,8 @@ def autodiscover_modules(*args, **kwargs):
raise
-if sys.version_info[:2] >= (3, 3):
- if sys.version_info[:2] >= (3, 4):
- from importlib.util import find_spec as importlib_find
- else:
- from importlib import find_loader as importlib_find
+if six.PY3:
+ from importlib.util import find_spec as importlib_find
def module_has_submodule(package, module_name):
"""See if 'module' is in 'package'."""