@@ -5144,13 +5144,13 @@ datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz)
51445144static PyObject *
51455145datetime_utcnow (PyObject * cls , PyObject * dummy )
51465146{
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+ }
51545154 return datetime_best_possible (cls , _PyTime_gmtime , Py_None );
51555155}
51565156
@@ -5187,13 +5187,13 @@ datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw)
51875187static PyObject *
51885188datetime_utcfromtimestamp (PyObject * cls , PyObject * args )
51895189{
5190- PyErr_WarnEx (
5191- PyExc_DeprecationWarning ,
5190+ if (PyErr_WarnEx (PyExc_DeprecationWarning ,
51925191 "datetime.utcfromtimestamp() is deprecated and scheduled for removal "
51935192 "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+ }
51975197 PyObject * timestamp ;
51985198 PyObject * result = NULL ;
51995199
0 commit comments