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);
}
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;