Skip to content

GH-103944: Check error status when raising DeprecationWarning #103949

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

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5144,13 +5144,13 @@ datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz)
static PyObject *
datetime_utcnow(PyObject *cls, PyObject *dummy)
{
PyErr_WarnEx(
PyExc_DeprecationWarning,
"datetime.utcnow() is deprecated and scheduled for removal in a future "
"version. Use timezone-aware objects to represent datetimes in UTC: "
"datetime.now(datetime.UTC).",
2
);
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"datetime.utcnow() is deprecated and scheduled for removal in a "
"future version. Use timezone-aware objects to represent datetimes "
"in UTC: datetime.now(datetime.UTC).", 2))
{
return NULL;
}
return datetime_best_possible(cls, _PyTime_gmtime, Py_None);
}

Expand Down Expand Up @@ -5187,13 +5187,13 @@ datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw)
static PyObject *
datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
{
PyErr_WarnEx(
PyExc_DeprecationWarning,
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"datetime.utcfromtimestamp() is deprecated and scheduled for removal "
"in a future version. Use timezone-aware objects to represent "
"datetimes in UTC: datetime.now(datetime.UTC).",
2
);
"datetimes in UTC: datetime.now(datetime.UTC).", 2))
{
return NULL;
}
PyObject *timestamp;
PyObject *result = NULL;

Expand Down