GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-72346: Added isdst deprecation warning to email.utils.localtime by alanfwilliams · Pull Request #91450 · python/cpython Conversation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm not sure why it says I haven't signed the CLA. I did just link it with my github account so it may take a moment to refresh I assume. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing and re-opening to re-trigger the CLA check. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
A good start, thanks!
It would need some documentation updating too.
Put a .. deprecated:: 3.11 under the function in email.utils.rst. For example, have a look at:
And also list it on "What’s New In Python 3.11":
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@hugovk I've added the edits you've requested. Thanks for the quick review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@hugovk I've completed the changes you requested. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just a couple of minor style things!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| .. versionadded:: 3.3 | ||
|
|
||
| .. deprecated:: 3.11 | ||
| Use of the ``isdst`` argument is deprecated. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I just noticed the style for parameters is italics (for example see the docstring):
| Use of the ``isdst`` argument is deprecated. | |
| Use of the *isdst* argument is deprecated. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| (Contributed by Brett Cannon in :issue:`47061`.) | ||
|
|
||
| * Deprecated the ``isdst`` parameter in :func:`email.utils.localtime`. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| * Deprecated the ``isdst`` parameter in :func:`email.utils.localtime`. | |
| * Deprecated the *isdst* parameter in :func:`email.utils.localtime`. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| """ | ||
| if isdst != -1: | ||
| warnings._deprecated("The isdst parameter to localtime", remove=(3,13)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
A little nit :)
| warnings._deprecated("The isdst parameter to localtime", remove=(3,13)) | |
| warnings._deprecated("The isdst parameter to localtime", remove=(3, 13)) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good! Hopefully a core dev can take a look soon and trigger the CI.
cc @abalkin, @bitdancer, @Mariatta
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi, just wanted to check if there was anything I could do to move this along. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is a great start! A few things to fix up, though.
There will also need to be test changes for this, both to test that the deprecation warning is emitted as expected, and to prevent it from escaping where we don't want it.
Also, note that I'm not a maintainer of the email package, so these are just general suggestions to hopefully make this quicker and easier for one of them to accept :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| to divine whether summer time is in effect for the specified time. | ||
|
|
||
| """ | ||
| if isdst != -1: |
There was a problem hiding this comment.
The 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 -1 explicitly. None is fine as the new default, or you could add _ignored = object() just before this function and use _ignored as the new default.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| warnings._deprecated("The isdst parameter to localtime", remove=(3,13)) | ||
| if dt is None: | ||
| return datetime.datetime.now(datetime.timezone.utc).astimezone() | ||
| if dt.tzinfo is not None: |
There was a problem hiding this comment.
The 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 datetime.astimezone():
if dt is None: dt = datetime.datetime.now() return dt.astimezone()
(Extra code for the deprecated parameter not shown :))
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| import socket | ||
| import datetime | ||
| import urllib.parse | ||
| import warnings |
There was a problem hiding this comment.
The 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 isdst, it can be imported where it's used.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| .. versionadded:: 3.3 | ||
|
|
||
| .. deprecated:: 3.11 |
There was a problem hiding this comment.
The 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 deprecated-removed directive here to also document when it will disappear.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -345,6 +346,8 @@ def localtime(dt=None, isdst=-1): | |||
| to divine whether summer time is in effect for the specified time. | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The docstring should be updated to remove everything about isdst, and replace it with a simple note that the parameter is ignored. Similar in the documentation.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| """ | ||
| if isdst != -1: | ||
| warnings._deprecated("The isdst parameter to localtime", remove=(3, 13)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the easy route here makes for an ugly message: 'The isdst argument to localtime' is deprecated .... We need to specify our own message to make it prettier:
| warnings._deprecated("The isdst parameter to localtime", remove=(3, 13)) | |
| warnings._deprecated( | |
| "The 'isdst' parameter to 'localtime'", | |
| message='{name} is deprecated and slated for removal in Python {remove}, | |
| remove=(3, 13), | |
| ) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| module: | ||
|
|
||
| .. function:: localtime(dt=None) | ||
| .. function:: localtime(dt=None, isdst=-1) |
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| (Contributed by Brett Cannon in :issue:`47061`.) | ||
|
|
||
| * Deprecated the *isdst* parameter in :func:`email.utils.localtime`. | ||
| (Contributed by Alan Williams in :issue:`72346`.) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
:issue:`72346` will direct to https://bugs.python.org/issue72346, which doesn't exist :). This should now be :gh:`72346` , IIUC.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Although it seems that the Azure test isn't working properly (says it passed in the output, but is marked as failed), I have made the requested changes; please review again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @zware: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hey @zware, any chance you can take a look at this? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
5 months later, yes! LGTM, sorry for the delay. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Deprecate isdst argument in email.utils.localtime
There was an error while loading. Please reload this page.