gh-91928: Add datetime.UTC alias for datetime.timezone.utc by Kab1r · Pull Request #91973 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation19 Commits8 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

Kab1r

fixes #91928

UTC is now module attribute aliased to datetime.timezone.utc.
You can now do the following:

Automerge-Triggered-By: GH:pganssle

@ghost

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot

pganssle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks!

In addition to my other comments, two other things:

  1. As I believe you are a first-time contributor, you should probably add your name to Misc/ACKS.
  2. Maybe add a very simple test to TestModule, like this:

def test_utc_alias(self): self.assertIs(UTC, timezone.utc)

Thanks for your contribution!

@bedevere-bot

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.

@Kab1r

I have made the requested changes; please review again

@bedevere-bot

Thanks for making the requested changes!

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

pganssle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this test?

Maybe add a very simple test to TestModule, like this:

def test_utc_alias(self): self.assertIs(UTC, timezone.utc)

@bedevere-bot

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.

@Kab1r

I had to move the definition of datetime.UTC to the end so that modifications to datetime.timezone.utc doesn't make it a different object.

@Kab1r

I have made the requested changes; please review again

@bedevere-bot

Thanks for making the requested changes!

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

@Kab1r @pganssle

@Kab1r @pganssle

@Kab1r @pganssle

@pganssle

  1. Add UTC definition into C implementation as well (just for consistency, there's no particular reason not to simply assign the alias in the Python code later).

  2. Move ..versionadded tag into the right place

pganssle

pganssle

@pganssle