bpo-37488 : Document a warning for datetime.utcnow() and utcfromtimestamp()#15773
bpo-37488 : Document a warning for datetime.utcnow() and utcfromtimestamp()#15773miss-islington merged 1 commit into
Conversation
|
@nanjekyejoannah I don't think we can (or possibly should) put an actual warning in the code here - people will likely complain about it and we're not actually deprecating the function yet, it will likely just cause a lot of uproar and spam (as much as I'd like to...). What I was referring to in bpo-15733 was a warning box in the documentation, like: .. warning::
Because naive datetimes are treated by many functions as local times,
it is recommended that you create a timezone-aware datetime using
``datetime.now(tz=timezone.utc)`` instead.I have not spent much time thinking about this. We may want a little footnote showing one of the gotchas to be referenced by both |
Sorry, something went wrong.
|
Okay. I had thought you wanted us to introduce a warning. I will update this PR accordingly. |
Sorry, something went wrong.
aeros
left a comment
There was a problem hiding this comment.
Thanks for the PR @nanjekyejoannah.
I have a few suggestions:
Sorry, something went wrong.
|
@nanjekyejoannah I believe this will have merge conflicts now that #13410 has been merged. Can you rebase against master? I also think adding a warning in |
Sorry, something went wrong.
2588293 to
2e5dc03
Compare
September 11, 2019 11:42
aeros
left a comment
There was a problem hiding this comment.
@nanjekyejoannah For consistency, can provide the warning message for each of them?
Because naive
datetimeobjects are treated by manydatetimemethods
as local times, the recommended way to create aware datetime objects for
the current time in UTC is by callingdatetime.now(timezone.utc).
Otherwise, everything else looks good to me.
Sorry, something went wrong.
This also removes several examples using utc* methods, to avoid confusion. bpo-37488: https://bugs.python.org/issue37488
7d9e901 to
84887b0
Compare
September 11, 2019 13:37
|
@nanjekyejoannah: Status check is done, and it's a success ✅ . |
Sorry, something went wrong.
…tamp() (pythonGH-15773) https://bugs.python.org/issue37488 Automerge-Triggered-By: @pganssle
|
Thanks @nanjekyejoannah for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
…tamp() (pythonGH-15773) https://bugs.python.org/issue37488 Automerge-Triggered-By: @pganssle (cherry picked from commit 1a53c78) Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
…tamp() (GH-15773) https://bugs.python.org/issue37488 Automerge-Triggered-By: @pganssle (cherry picked from commit 1a53c78) Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
https://bugs.python.org/issue37488
Automerge-Triggered-By: @pganssle