Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-118798: Remove deprecated isdst parameter from email.utils.localtime #118799

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Doc/library/email.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.)
Expand Down
10 changes: 1 addition & 9 deletions Lib/email/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 0 additions & 4 deletions Lib/test/test_email/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ def test_variable_tzname(self):
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The *isdst* parameter has been removed from :func:`email.utils.localtime`.
Patch by Hugo van Kemenade.
Loading