-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-72346: Added isdst deprecation warning to email.utils.localtime #91450
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
Changes from 6 commits
dadf5e2
77414f9
add07f3
854ebf8
1b9a60f
6784b42
1bd66a2
d3fd3f2
b30f940
354eff2
36365fe
44f025c
7125e78
cdea718
6b0ccbb
47474c9
0d3c5bf
9f59d33
ae687b0
c214c4f
7cacc5f
0633911
e483ed6
bf4b0c6
a63a5e4
8807fa1
318ef9e
718888c
9389791
672b5e5
89eb11a
c2b4c94
31a4c46
54596ef
d0eda9d
ecc3bff
8151b5a
4c3413a
7ff165e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| There are a couple of useful utilities provided in the :mod:`email.utils` | ||
| module: | ||
|
|
||
| .. function:: localtime(dt=None) | ||
| .. function:: localtime(dt=None, isdst=-1) | ||
|
|
||
| Return local time as an aware datetime object. If called without | ||
| arguments, return current time. Otherwise *dt* argument should be a | ||
|
|
@@ -26,6 +26,8 @@ module: | |
|
|
||
| .. versionadded:: 3.3 | ||
|
|
||
| .. deprecated:: 3.11 | ||
|
alanfwilliams marked this conversation as resolved.
Outdated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're specifying in the code that it will be removed in 3.13, we can use the |
||
| Use of the *isdst* argument is deprecated. | ||
|
|
||
| .. function:: make_msgid(idstring=None, domain=None) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -853,6 +853,9 @@ Deprecated | |
|
|
||
| (Contributed by Brett Cannon in :issue:`47061`.) | ||
|
|
||
| * Deprecated the *isdst* parameter in :func:`email.utils.localtime`. | ||
| (Contributed by Alan Williams in :issue:`72346`.) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
|
|
||
| Removed | ||
| ======= | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |||||||||||||
| import socket | ||||||||||||||
| import datetime | ||||||||||||||
| import urllib.parse | ||||||||||||||
| import warnings | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this should generally not be necessary unless someone is passing in a value for |
||||||||||||||
|
|
||||||||||||||
| from email._parseaddr import quote | ||||||||||||||
| from email._parseaddr import AddressList as _AddressList | ||||||||||||||
|
|
@@ -345,6 +346,8 @@ def localtime(dt=None, isdst=-1): | |||||||||||||
| to divine whether summer time is in effect for the specified time. | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docstring should be updated to remove everything about |
||||||||||||||
|
|
||||||||||||||
| """ | ||||||||||||||
| if isdst != -1: | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to change the default value here to detect when someone is passing in |
||||||||||||||
| warnings._deprecated("The isdst parameter to localtime", remove=(3, 13)) | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, the easy route here makes for an ugly message:
Suggested change
|
||||||||||||||
| if dt is None: | ||||||||||||||
| return datetime.datetime.now(datetime.timezone.utc).astimezone() | ||||||||||||||
| if dt.tzinfo is not None: | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in the issue, this whole function can be reduced to just a thin wrapper around if dt is None:
dt = datetime.datetime.now()
return dt.astimezone()(Extra code for the deprecated parameter not shown :)) |
||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Added deprecation warning to isdst parameter of email.utils.localtime. | ||
|
alanfwilliams marked this conversation as resolved.
Outdated
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it wasn't documented before and is being removed, we probably don't want to add it now :). The deprecation note can mention that it was previously undocumented.