summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>2024-05-09 09:17:02 (GMT)
committerGitHub <noreply@github.com>2024-05-09 09:17:02 (GMT)
commitc68acb1384a51eb745f572687eaf677371b9e765 (patch)
tree6c6bdebc7f82d1ea2a29af1e3240ecfbd782c469
parentfa9b9cb11379806843ae03b1e4ad4ccd95a63c02 (diff)
downloadcpython-c68acb1384a51eb745f572687eaf677371b9e765.zip
cpython-c68acb1384a51eb745f572687eaf677371b9e765.tar.gz
cpython-c68acb1384a51eb745f572687eaf677371b9e765.tar.bz2
gh-118798: Remove deprecated isdst parameter from `email.utils.localtime` (#118799)
-rw-r--r--Doc/library/email.utils.rst3
-rw-r--r--Doc/whatsnew/3.14.rst9
-rw-r--r--Lib/email/utils.py10
-rw-r--r--Lib/test/test_email/test_utils.py4
-rw-r--r--Misc/NEWS.d/next/Library/2024-05-08-23-16-50.gh-issue-118798.Q_ybqP.rst2
5 files changed, 13 insertions, 15 deletions
diff --git a/Doc/library/email.utils.rst b/Doc/library/email.utils.rst
index 6f0bed1..43e5b25 100644
--- a/Doc/library/email.utils.rst
+++ b/Doc/library/email.utils.rst
@@ -17,8 +17,7 @@ module:
arguments, return current time. Otherwise *dt* argument should be a
:class:`~datetime.datetime` instance, and it is converted to the local time
zone according to the system time zone database. If *dt* is naive (that
- is, ``dt.tzinfo`` is ``None``), it is assumed to be in local time. The
- *isdst* parameter is ignored.
+ is, ``dt.tzinfo`` is ``None``), it is assumed to be in local time.
.. versionadded:: 3.3
diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index 496a5d8..24b6b61 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -101,6 +101,15 @@ Deprecated
Removed
=======
+email
+-----
+
+* The *isdst* parameter has been removed from :func:`email.utils.localtime`.
+ (Contributed by Hugo van Kemenade in :gh:`118798`.)
+
+Others
+------
+
* Using :data:`NotImplemented` in a boolean context will now raise a :exc:`TypeError`.
It had previously raised a :exc:`DeprecationWarning` since Python 3.9. (Contributed
by Jelle Zijlstra in :gh:`118767`.)
diff --git a/Lib/email/utils.py b/Lib/email/utils.py
index 103cef6..6d897ca 100644
--- a/Lib/email/utils.py
+++ b/Lib/email/utils.py
@@ -466,23 +466,15 @@ def collapse_rfc2231_value(value, errors='replace',
# better than not having it.
#
-def localtime(dt=None, isdst=None):
+def localtime(dt=None):
"""Return local time as an aware datetime object.
If called without arguments, return current time. Otherwise *dt*
argument should be a datetime instance, and it is converted to the
local time zone according to the system time zone database. If *dt* is
naive (that is, dt.tzinfo is None), it is assumed to be in local time.
- The isdst parameter is ignored.
"""
- if isdst is not None:
- import warnings
- warnings._deprecated(
- "The 'isdst' parameter to 'localtime'",
- message='{name} is deprecated and slated for removal in Python {remove}',
- remove=(3, 14),
- )
if dt is None:
dt = datetime.datetime.now()
return dt.astimezone()
diff --git a/Lib/test/test_email/test_utils.py b/Lib/test/test_email/test_utils.py
index d04b390..8556a93 100644
--- a/Lib/test/test_email/test_utils.py
+++ b/Lib/test/test_email/test_utils.py
@@ -154,10 +154,6 @@ class LocaltimeTests(unittest.TestCase):
t1 = utils.localtime(t0)
self.assertEqual(t1.tzname(), 'EET')
- def test_isdst_deprecation(self):
- with self.assertWarns(DeprecationWarning):
- t0 = datetime.datetime(1990, 1, 1)
- t1 = utils.localtime(t0, isdst=True)
# Issue #24836: The timezone files are out of date (pre 2011k)
# on Mac OS X Snow Leopard.
diff --git a/Misc/NEWS.d/next/Library/2024-05-08-23-16-50.gh-issue-118798.Q_ybqP.rst b/Misc/NEWS.d/next/Library/2024-05-08-23-16-50.gh-issue-118798.Q_ybqP.rst
new file mode 100644
index 0000000..28847e1
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-05-08-23-16-50.gh-issue-118798.Q_ybqP.rst
@@ -0,0 +1,2 @@
+The *isdst* parameter has been removed from :func:`email.utils.localtime`.
+Patch by Hugo van Kemenade.