mirror of https://github.com/python/cpython
GH-103944: Check error status when raising DeprecationWarning (#103949)
This commit is contained in:
parent
ebf97c50f2
commit
689723a4ab
|
@ -5144,13 +5144,13 @@ datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
datetime_utcnow(PyObject *cls, PyObject *dummy)
|
datetime_utcnow(PyObject *cls, PyObject *dummy)
|
||||||
{
|
{
|
||||||
PyErr_WarnEx(
|
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
PyExc_DeprecationWarning,
|
"datetime.utcnow() is deprecated and scheduled for removal in a "
|
||||||
"datetime.utcnow() is deprecated and scheduled for removal in a future "
|
"future version. Use timezone-aware objects to represent datetimes "
|
||||||
"version. Use timezone-aware objects to represent datetimes in UTC: "
|
"in UTC: datetime.now(datetime.UTC).", 2))
|
||||||
"datetime.now(datetime.UTC).",
|
{
|
||||||
2
|
return NULL;
|
||||||
);
|
}
|
||||||
return datetime_best_possible(cls, _PyTime_gmtime, Py_None);
|
return datetime_best_possible(cls, _PyTime_gmtime, Py_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5187,13 +5187,13 @@ datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
|
datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
|
||||||
{
|
{
|
||||||
PyErr_WarnEx(
|
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
PyExc_DeprecationWarning,
|
|
||||||
"datetime.utcfromtimestamp() is deprecated and scheduled for removal "
|
"datetime.utcfromtimestamp() is deprecated and scheduled for removal "
|
||||||
"in a future version. Use timezone-aware objects to represent "
|
"in a future version. Use timezone-aware objects to represent "
|
||||||
"datetimes in UTC: datetime.now(datetime.UTC).",
|
"datetimes in UTC: datetime.now(datetime.UTC).", 2))
|
||||||
2
|
{
|
||||||
);
|
return NULL;
|
||||||
|
}
|
||||||
PyObject *timestamp;
|
PyObject *timestamp;
|
||||||
PyObject *result = NULL;
|
PyObject *result = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue