@@ -5144,13 +5144,13 @@ datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz)
5144
5144
static PyObject *
5145
5145
datetime_utcnow (PyObject * cls , PyObject * dummy )
5146
5146
{
5147
- PyErr_WarnEx (
5148
- PyExc_DeprecationWarning ,
5149
- "datetime.utcnow() is deprecated and scheduled for removal in a future "
5150
- "version. Use timezone-aware objects to represent datetimes in UTC: "
5151
- "datetime.now(datetime.UTC)." ,
5152
- 2
5153
- );
5147
+ if ( PyErr_WarnEx (PyExc_DeprecationWarning ,
5148
+ "datetime.utcnow() is deprecated and scheduled for removal in a "
5149
+ "future version. Use timezone-aware objects to represent datetimes "
5150
+ "in UTC: datetime.now(datetime.UTC)." , 2 ))
5151
+ {
5152
+ return NULL ;
5153
+ }
5154
5154
return datetime_best_possible (cls , _PyTime_gmtime , Py_None );
5155
5155
}
5156
5156
@@ -5187,13 +5187,13 @@ datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw)
5187
5187
static PyObject *
5188
5188
datetime_utcfromtimestamp (PyObject * cls , PyObject * args )
5189
5189
{
5190
- PyErr_WarnEx (
5191
- PyExc_DeprecationWarning ,
5190
+ if (PyErr_WarnEx (PyExc_DeprecationWarning ,
5192
5191
"datetime.utcfromtimestamp() is deprecated and scheduled for removal "
5193
5192
"in a future version. Use timezone-aware objects to represent "
5194
- "datetimes in UTC: datetime.now(datetime.UTC)." ,
5195
- 2
5196
- );
5193
+ "datetimes in UTC: datetime.now(datetime.UTC)." , 2 ))
5194
+ {
5195
+ return NULL ;
5196
+ }
5197
5197
PyObject * timestamp ;
5198
5198
PyObject * result = NULL ;
5199
5199
0 commit comments