Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-103944: Remove last use ofutcfromtimestamp#103995

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

Already on GitHub?Sign in to your account

Merged
pganssle merged 3 commits intopython:mainfrompganssle:utcnow_deprecation
May 3, 2023

Conversation

pganssle
Copy link
Member

@pgansslepganssle commentedApr 29, 2023
edited by bedevere-bot
Loading

I guess we missed a few places whereDeprecationWarning was being raised in the first round of this.

This should pass./python -We -m test -v test_datetime now.

@pgansslepganssle changed the title#103944: Remove last use ofutcfromtimestampGH-103944: Remove last use ofutcfromtimestampApr 29, 2023
sign = int(ts / ats)

ts, frac = divmod(ats, 1.)
ts *= sign
Copy link
Member

@abalkinabalkinApr 30, 2023
edited
Loading

Choose a reason for hiding this comment

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

We can use math.copysign to copy sign directly from to here for a more efficient implementation.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yeah, this whole thing was an effort to avoid importingmath, so it's something of a re-implementation ofmath.modf. At the end of the day that seems... pointless, particularly for the test suite, so I just went ahead and usedmath.modf.

abalkin reacted with thumbs up emoji
# XXX Copied from test_float.
INF = float("inf")
NAN = float("nan")


def _utcfromtimestamp(klass, ts):
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why simple timedelta arithmetic will not work here:

def_utcfromtimestamp(klass,ts):returnklass(1970,1,1)+timedelta(seconds=ts)

Copy link
Member

Choose a reason for hiding this comment

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

@pganssle - I ran test_datetime locally with this variant and all test cases pass. I am not sure I can push to your branch, but I will try to submit this change somehow to CI.

Copy link
Member

Choose a reason for hiding this comment

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

Frankly, given that this is only used in tests, I am not sure how much effort is justified in polishing this, but it is probably good to keep test code simple.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good idea, I was just kinda mindlessly copying the implementation fromdatetime, but usingtimedelta arithmetic is much more elegant.

It's also only used in the one place, so I just inlined it.

There might be easier ways to do this in the future, or we may be ableto avoid it entirely by switching to `ZoneInfo` for these tests, butthis will remove the last valid use of `utcfromtimetamp` that I see.
In one test, we simply turn off DeprecationWarning rather than assertingabout it, because whether the error condition happens before or afterthe warning seems to differ between the Python and C versions.
@pganssle
Copy link
MemberAuthor

OK, I think that the DeprecationWarnings might be breaking a buildbot or otherwise making it hard to run the test suite, so I am going to go ahead and merge this.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@abalkinabalkinabalkin left review comments

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@pganssle@abalkin@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp