summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2019-02-04 18:53:11 -0500
committerGitHub <noreply@github.com>2019-02-04 18:53:11 -0500
commit83c2bc52c2bf6da682989867b09c753ec1a2e5b3 (patch)
treec079c7aaf904532ca795a4ac11985e8646385e47
parentfdc4518fe296c169cf54f23fdad2e0fc8785c059 (diff)
Refs #27753 -- Deprecated django.utils.http urllib aliases.
-rw-r--r--django/utils/http.py22
-rw-r--r--docs/internals/deprecation.txt3
-rw-r--r--docs/releases/3.0.txt6
-rw-r--r--tests/utils_tests/test_http.py4
4 files changed, 33 insertions, 2 deletions
diff --git a/django/utils/http.py b/django/utils/http.py
index 7b4f4996d7..3def0e02a6 100644
--- a/django/utils/http.py
+++ b/django/utils/http.py
@@ -3,6 +3,7 @@ import calendar
import datetime
import re
import unicodedata
+import warnings
from binascii import Error as BinasciiError
from email.utils import formatdate
from urllib.parse import (
@@ -13,6 +14,7 @@ from urllib.parse import (
from django.core.exceptions import TooManyFieldsSent
from django.utils.datastructures import MultiValueDict
+from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.functional import keep_lazy_text
# based on RFC 7232, Appendix C
@@ -48,6 +50,11 @@ def urlquote(url, safe='/'):
A legacy compatibility wrapper to Python's urllib.parse.quote() function.
(was used for unicode handling on Python 2)
"""
+ warnings.warn(
+ 'django.utils.http.urlquote() is deprecated in favor of '
+ 'urllib.parse.quote().',
+ RemovedInDjango40Warning, stacklevel=2,
+ )
return quote(url, safe)
@@ -57,6 +64,11 @@ def urlquote_plus(url, safe=''):
A legacy compatibility wrapper to Python's urllib.parse.quote_plus()
function. (was used for unicode handling on Python 2)
"""
+ warnings.warn(
+ 'django.utils.http.urlquote_plus() is deprecated in favor of '
+ 'urllib.parse.quote_plus(),',
+ RemovedInDjango40Warning, stacklevel=2,
+ )
return quote_plus(url, safe)
@@ -66,6 +78,11 @@ def urlunquote(quoted_url):
A legacy compatibility wrapper to Python's urllib.parse.unquote() function.
(was used for unicode handling on Python 2)
"""
+ warnings.warn(
+ 'django.utils.http.urlunquote() is deprecated in favor of '
+ 'urllib.parse.unquote().',
+ RemovedInDjango40Warning, stacklevel=2,
+ )
return unquote(quoted_url)
@@ -75,6 +92,11 @@ def urlunquote_plus(quoted_url):
A legacy compatibility wrapper to Python's urllib.parse.unquote_plus()
function. (was used for unicode handling on Python 2)
"""
+ warnings.warn(
+ 'django.utils.http.urlunquote_plus() is deprecated in favor of '
+ 'urllib.parse.unquote_plus().',
+ RemovedInDjango40Warning, stacklevel=2,
+ )
return unquote_plus(quoted_url)
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 1a5b98df33..0550c10ec7 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -15,6 +15,9 @@ about each item can often be found in the release notes of two versions prior.
See the :ref:`Django 3.0 release notes <deprecated-features-3.0>` for more
details on these changes.
+* ``django.utils.http.urlquote()``, ``urlquote_plus()``, ``urlunquote()``, and
+ ``urlunquote_plus()`` will be removed.
+
.. _deprecation-removed-in-3.1:
3.1
diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt
index 4eca26bbca..4dda131dbc 100644
--- a/docs/releases/3.0.txt
+++ b/docs/releases/3.0.txt
@@ -248,7 +248,11 @@ Features deprecated in 3.0
Miscellaneous
-------------
-* ...
+* ``django.utils.http.urlquote()``, ``urlquote_plus()``, ``urlunquote()``, and
+ ``urlunquote_plus()`` are deprecated in favor of the functions that they're
+ aliases for: :func:`urllib.parse.quote`, :func:`~urllib.parse.quote_plus`,
+ :func:`~urllib.parse.unquote`, and :func:`~urllib.parse.unquote_plus`.
+
.. _removed-features-3.0:
diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py
index d143b34e7b..05628431c3 100644
--- a/tests/utils_tests/test_http.py
+++ b/tests/utils_tests/test_http.py
@@ -1,8 +1,9 @@
import unittest
from datetime import datetime
-from django.test import SimpleTestCase
+from django.test import SimpleTestCase, ignore_warnings
from django.utils.datastructures import MultiValueDict
+from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.http import (
base36_to_int, escape_leading_slashes, http_date, int_to_base36,
is_safe_url, is_same_domain, parse_etags, parse_http_date, quote_etag,
@@ -216,6 +217,7 @@ class URLSafeBase64Tests(unittest.TestCase):
self.assertEqual(bytestring, decoded)
+@ignore_warnings(category=RemovedInDjango40Warning)
class URLQuoteTests(unittest.TestCase):
def test_quote(self):
self.assertEqual(urlquote('Paris & Orl\xe9ans'), 'Paris%20%26%20Orl%C3%A9ans')