diff --git a/django/utils/http.py b/django/utils/http.py index de1ea71368..7b4f4996d7 100644 --- a/django/utils/http.py +++ b/django/utils/http.py @@ -3,7 +3,6 @@ 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 ( @@ -14,7 +13,6 @@ from urllib.parse import ( from django.core.exceptions import TooManyFieldsSent from django.utils.datastructures import MultiValueDict -from django.utils.deprecation import RemovedInDjango30Warning from django.utils.functional import keep_lazy_text # based on RFC 7232, Appendix C @@ -120,25 +118,6 @@ def urlencode(query, doseq=False): return original_urlencode(query_params, doseq) -def cookie_date(epoch_seconds=None): - """ - Format the time to ensure compatibility with Netscape's cookie standard. - - `epoch_seconds` is a floating point number expressed in seconds since the - epoch, in UTC - such as that outputted by time.time(). If set to None, it - defaults to the current time. - - Output a string in the format 'Wdy, DD-Mon-YYYY HH:MM:SS GMT'. - """ - warnings.warn( - 'cookie_date() is deprecated in favor of http_date(), which follows ' - 'the format of the latest RFC.', - RemovedInDjango30Warning, stacklevel=2, - ) - rfcdate = formatdate(epoch_seconds) - return '%s-%s-%s GMT' % (rfcdate[:7], rfcdate[8:11], rfcdate[12:25]) - - def http_date(epoch_seconds=None): """ Format the time to match the RFC1123 date format as specified by HTTP diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 6a7d4b6549..84cffddde0 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -700,20 +700,6 @@ escaping HTML. A version of Python's :func:`urllib.parse.urlencode` function that can operate on ``MultiValueDict`` and non-string values. -.. function:: cookie_date(epoch_seconds=None) - - .. deprecated:: 2.1 - - Use :func:`http_date` instead, which follows the latest RFC. - - Formats the time to ensure compatibility with Netscape's cookie standard. - - Accepts a floating point number expressed in seconds since the epoch in - UTC--such as that outputted by ``time.time()``. If set to ``None``, - defaults to the current time. - - Outputs a string in the format ``Wdy, DD-Mon-YYYY HH:MM:SS GMT``. - .. function:: http_date(epoch_seconds=None) Formats the time to match the :rfc:`1123` date format as specified by HTTP diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt index ac7c3d0638..99db02a0aa 100644 --- a/docs/releases/3.0.txt +++ b/docs/releases/3.0.txt @@ -254,3 +254,5 @@ See :ref:`deprecated-features-2.1` for details on these changes, including how to remove usage of these features. * The ``ForceRHR`` GIS function is removed. + +* ``django.utils.http.cookie_date()`` is removed. diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py index aca825ef1f..d143b34e7b 100644 --- a/tests/utils_tests/test_http.py +++ b/tests/utils_tests/test_http.py @@ -1,13 +1,12 @@ import unittest from datetime import datetime -from django.test import SimpleTestCase, ignore_warnings +from django.test import SimpleTestCase from django.utils.datastructures import MultiValueDict -from django.utils.deprecation import RemovedInDjango30Warning from django.utils.http import ( - base36_to_int, cookie_date, escape_leading_slashes, http_date, - int_to_base36, is_safe_url, is_same_domain, parse_etags, parse_http_date, - quote_etag, urlencode, urlquote, urlquote_plus, urlsafe_base64_decode, + base36_to_int, escape_leading_slashes, http_date, int_to_base36, + is_safe_url, is_same_domain, parse_etags, parse_http_date, quote_etag, + urlencode, urlquote, urlquote_plus, urlsafe_base64_decode, urlsafe_base64_encode, urlunquote, urlunquote_plus, ) @@ -279,11 +278,6 @@ class HttpDateProcessingTests(unittest.TestCase): t = 1167616461.0 self.assertEqual(http_date(t), 'Mon, 01 Jan 2007 01:54:21 GMT') - @ignore_warnings(category=RemovedInDjango30Warning) - def test_cookie_date(self): - t = 1167616461.0 - self.assertEqual(cookie_date(t), 'Mon, 01-Jan-2007 01:54:21 GMT') - def test_parsing_rfc1123(self): parsed = parse_http_date('Sun, 06 Nov 1994 08:49:37 GMT') self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37))