GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-72346: Added isdst deprecation warning to email.utils.localtime by alanfwilliams · Pull Request #91450 · python/cpython

Conversation

@alanfwilliams

@alanfwilliams alanfwilliams commented Apr 11, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This adds a deprecation warning to the isdst parameter in email.utils.localtime. This is my first contribution so any feedback is welcome.

  • Issue: Deprecate isdst argument in email.utils.localtime #72346

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@alanfwilliams
Added isdst deprecation warning
dadf5e2
@alanfwilliams
alanfwilliams requested a review from a team as a code owner April 11, 2022 18:31
@bedevere-bot bedevere-bot added the awaiting review label Apr 11, 2022
@blurb-it
📜🤖 Added by blurb_it.
77414f9
@ghost

This comment was marked as outdated.

Sign in to view
@alanfwilliams

alanfwilliams commented Apr 11, 2022

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zware

zware commented Apr 11, 2022

Copy link
Copy Markdown
Member

Closing and re-opening to re-trigger the CLA check.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zware zware closed this Apr 11, 2022
@zware zware reopened this Apr 11, 2022
@zware zware linked an issue Apr 12, 2022 that may be closed by this pull request
Deprecate isdst argument in email.utils.localtime #72346
Closed
hugovk
hugovk reviewed Apr 12, 2022
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

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.

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:

  • https://docs.python.org/3.11/library/gzip.html#gzip.GzipFile.mtime
  • https://github.com/python/cpython/blob/main/Doc/library/gzip.rst

And also list it on "What’s New In Python 3.11":

  • https://docs.python.org/3.11/whatsnew/3.11.html#deprecated
  • https://github.com/python/cpython/blob/main/Doc/whatsnew/3.11.rst

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/email/utils.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@alanfwilliams
added documentation and used _deprecated
add07f3
@alanfwilliams

alanfwilliams commented Apr 12, 2022

Copy link
Copy Markdown
Contributor Author

@hugovk I've added the edits you've requested. Thanks for the quick review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alanfwilliams
Removed trailing whitespace.
854ebf8
hugovk
hugovk reviewed Apr 12, 2022
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

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.

Thanks for the update!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/whatsnew/3.11.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/email.utils.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/email/utils.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@alanfwilliams
added newline, moved whatsnew, reformatted warning
1b9a60f
@alanfwilliams

alanfwilliams commented Apr 13, 2022

Copy link
Copy Markdown
Contributor Author

@hugovk I've completed the changes you requested.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk
hugovk reviewed Apr 13, 2022
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

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.

Thanks! Just a couple of minor style things!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/email.utils.rst Outdated
.. versionadded:: 3.3

.. deprecated:: 3.11
Use of the ``isdst`` argument is deprecated.

@hugovk hugovk Apr 13, 2022

Copy link
Copy Markdown
Member

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.

I just noticed the style for parameters is italics (for example see the docstring):

Suggested change
Use of the ``isdst`` argument is deprecated.
Use of the *isdst* argument is deprecated.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/whatsnew/3.11.rst Outdated

(Contributed by Brett Cannon in :issue:`47061`.)

* Deprecated the ``isdst`` parameter in :func:`email.utils.localtime`.

@hugovk hugovk Apr 13, 2022

Copy link
Copy Markdown
Member

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.

Suggested change
* Deprecated the ``isdst`` parameter in :func:`email.utils.localtime`.
* Deprecated the *isdst* parameter in :func:`email.utils.localtime`.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/email/utils.py Outdated

"""
if isdst != -1:
warnings._deprecated("The isdst parameter to localtime", remove=(3,13))

@hugovk hugovk Apr 13, 2022

Copy link
Copy Markdown
Member

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.

A little nit :)

Suggested change
warnings._deprecated("The isdst parameter to localtime", remove=(3,13))
warnings._deprecated("The isdst parameter to localtime", remove=(3, 13))

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@alanfwilliams
formatting corrections
6784b42
hugovk
hugovk approved these changes Apr 13, 2022
View reviewed changes

@hugovk hugovk left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Thanks, looks good! Hopefully a core dev can take a look soon and trigger the CI.

cc @abalkin, @bitdancer, @Mariatta

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting core review and removed awaiting review labels Apr 13, 2022
@hugovk hugovk added topic-email stdlib Standard Library Python modules in the Lib/ directory 3.11 only security fixes labels Apr 13, 2022
@alanfwilliams

alanfwilliams commented Apr 26, 2022

Copy link
Copy Markdown
Contributor Author

Hi, just wanted to check if there was anything I could do to move this along.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zware
zware requested changes Apr 26, 2022
View reviewed changes

@zware zware left a comment

Copy link
Copy Markdown
Member

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/email/utils.py Outdated
to divine whether summer time is in effect for the specified time.

"""
if isdst != -1:

@zware zware Apr 13, 2022

Copy link
Copy Markdown
Member

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/email/utils.py Outdated
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:

@zware zware Apr 13, 2022

Copy link
Copy Markdown
Member

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/email/utils.py Outdated
import socket
import datetime
import urllib.parse
import warnings

@zware zware Apr 13, 2022

Copy link
Copy Markdown
Member

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 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/email.utils.rst Outdated

.. versionadded:: 3.3

.. deprecated:: 3.11

@zware zware Apr 13, 2022

Copy link
Copy Markdown
Member

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 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/email/utils.py Outdated
@@ -345,6 +346,8 @@ def localtime(dt=None, isdst=-1):
to divine whether summer time is in effect for the specified time.

@zware zware Apr 13, 2022

Copy link
Copy Markdown
Member

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/email/utils.py Outdated

"""
if isdst != -1:
warnings._deprecated("The isdst parameter to localtime", remove=(3, 13))

@zware zware Apr 16, 2022

Copy link
Copy Markdown
Member

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.

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:

Suggested change
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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/email.utils.rst Outdated
module:

.. function:: localtime(dt=None)
.. function:: localtime(dt=None, isdst=-1)

@zware zware Apr 26, 2022

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/whatsnew/3.11.rst Outdated
(Contributed by Brett Cannon in :issue:`47061`.)

* Deprecated the *isdst* parameter in :func:`email.utils.localtime`.
(Contributed by Alan Williams in :issue:`72346`.)

@zware zware Apr 26, 2022

Copy link
Copy Markdown
Member

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.

: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.

Uh oh!

There was an error while loading. Please reload this page.

ezio-melotti reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-bot bedevere-bot added awaiting changes and removed awaiting core review labels Apr 26, 2022
@bedevere-bot

bedevere-bot commented Apr 26, 2022

Copy link
Copy Markdown

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ezio-melotti
ezio-melotti reviewed Aug 30, 2022
View reviewed changes
Comment thread Lib/email/utils.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

ezio-melotti and others added 6 commits August 30, 2022 23:23
@ezio-melotti
Revert incorrect change.
9389791
@alanfwilliams
Merge branch 'fix-pythongh-72346' of https://github.com/aw1231/cpython …
672b5e5
…into fix-pythongh-72346
@alanfwilliams
Merge branch 'main' into fix-pythongh-72346
89eb11a
@alanfwilliams
Merge branch 'fix-pythongh-72346' of https://github.com/aw1231/cpython …
c2b4c94
…into fix-pythongh-72346
@alanfwilliams
Modified existing tests/added test for deprecation
31a4c46
@alanfwilliams
Merge branch 'main' into fix-pythongh-72346
54596ef
hugovk
hugovk reviewed Sep 8, 2022
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

alanfwilliams added 2 commits September 8, 2022 10:26
@alanfwilliams
Moved whatsnew note
d0eda9d
@alanfwilliams
Merge branch 'fix-pythongh-72346' of https://github.com/aw1231/cpython …
ecc3bff
…into fix-pythongh-72346
@alanfwilliams

alanfwilliams commented Sep 8, 2022

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting change review and removed awaiting changes labels Sep 8, 2022
@bedevere-bot

bedevere-bot commented Sep 8, 2022

Copy link
Copy Markdown

Thanks for making the requested changes!

@zware: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot
bedevere-bot requested a review from zware September 8, 2022 18:49
alanfwilliams added 3 commits October 7, 2022 13:38
@alanfwilliams
Merge branch 'main' into fix-pythongh-72346
8151b5a
@alanfwilliams
Adjust formatting
4c3413a
@alanfwilliams
Merge branch 'main' into fix-pythongh-72346
7ff165e
@alanfwilliams

alanfwilliams commented Oct 21, 2022

Copy link
Copy Markdown
Contributor Author

Hey @zware, any chance you can take a look at this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zware
zware approved these changes Mar 20, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting change review labels Mar 20, 2023
@zware

zware commented Mar 20, 2023

Copy link
Copy Markdown
Member

5 months later, yes! LGTM, sorry for the delay.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zware
zware merged commit 5e6661b into python:main Mar 20, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Mar 20, 2023
@zware zware added 3.12 only security fixes and removed 3.11 only security fixes labels Mar 20, 2023
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
@alanfwilliams @Fidget-Spinner
pythongh-72346: Added isdst deprecation warning to email.utils.localt…
7dab359
…ime (pythonGH-91450)
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
@alanfwilliams @warsaw
pythongh-72346: Added isdst deprecation warning to email.utils.localt…
a715639
…ime (pythonGH-91450)
@hugovk hugovk mentioned this pull request May 8, 2024
Remove isdst parameter from email.utils.localtime #118798
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk approved these changes
@ezio-melotti ezio-melotti ezio-melotti left review comments
@zware zware zware approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

3.12 only security fixes stdlib Standard Library Python modules in the Lib/ directory topic-email

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Deprecate isdst argument in email.utils.localtime

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@alanfwilliams @zware @bedevere-bot @hugovk @ezio-melotti
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.