Skip to content
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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-118542: improve datetime deprecation warnings #118571

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve datetime utc deprecation warnings.
8 changes: 5 additions & 3 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5199,7 +5199,8 @@ datetime_utcnow(PyObject *cls, PyObject *dummy)
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"datetime.datetime.utcnow() is deprecated and scheduled for removal in a "
"future version. Use timezone-aware objects to represent datetimes "
"in UTC: datetime.datetime.now(datetime.UTC).", 1))
"in UTC: datetime.datetime.now(datetime.UTC). To maintain compatability"
Max-Herbold marked this conversation as resolved.
Show resolved Hide resolved
"datetime.datetime.now(datetime.UTC).replace(tzinfo=None) may be used.", 1))
Max-Herbold marked this conversation as resolved.
Show resolved Hide resolved
{
return NULL;
}
Expand Down Expand Up @@ -5241,8 +5242,9 @@ datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
{
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal "
"in a future version. Use timezone-aware objects to represent "
"datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).", 1))
"in a future version. Use timezone-aware objects to represent datetimes "
"in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC). To maintain "
"compatability datetime.datetime.fromtimestamp(timestamp) may be used.", 1))
Max-Herbold marked this conversation as resolved.
Show resolved Hide resolved
{
return NULL;
}
Expand Down