@@ -3955,15 +3955,21 @@ time_getstate(PyDateTime_Time *self, int proto)
39553955}
39563956
39573957static PyObject *
3958- time_reduce (PyDateTime_Time * self , PyObject * args )
3958+ time_reduce_ex (PyDateTime_Time * self , PyObject * args )
39593959{
3960- int proto = 0 ;
3961- if (!PyArg_ParseTuple (args , "| i:__reduce_ex__" , & proto ))
3960+ int proto ;
3961+ if (!PyArg_ParseTuple (args , "i:__reduce_ex__" , & proto ))
39623962 return NULL ;
39633963
39643964 return Py_BuildValue ("(ON)" , Py_TYPE (self ), time_getstate (self , proto ));
39653965}
39663966
3967+ static PyObject *
3968+ time_reduce (PyDateTime_Time * self , PyObject * arg )
3969+ {
3970+ return Py_BuildValue ("(ON)" , Py_TYPE (self ), time_getstate (self , 2 ));
3971+ }
3972+
39673973static PyMethodDef time_methods [] = {
39683974
39693975 {"isoformat" , (PyCFunction )time_isoformat , METH_VARARGS | METH_KEYWORDS ,
@@ -3989,9 +3995,12 @@ static PyMethodDef time_methods[] = {
39893995 {"replace" , (PyCFunction )time_replace , METH_VARARGS | METH_KEYWORDS ,
39903996 PyDoc_STR ("Return time with new specified fields." )},
39913997
3992- {"__reduce_ex__" , (PyCFunction )time_reduce , METH_VARARGS ,
3998+ {"__reduce_ex__" , (PyCFunction )time_reduce_ex , METH_VARARGS ,
39933999 PyDoc_STR ("__reduce_ex__(proto) -> (cls, state)" )},
39944000
4001+ {"__reduce__" , (PyCFunction )time_reduce , METH_NOARGS ,
4002+ PyDoc_STR ("__reduce__() -> (cls, state)" )},
4003+
39954004 {NULL , NULL }
39964005};
39974006
@@ -5420,15 +5429,21 @@ datetime_getstate(PyDateTime_DateTime *self, int proto)
54205429}
54215430
54225431static PyObject *
5423- datetime_reduce (PyDateTime_DateTime * self , PyObject * args )
5432+ datetime_reduce_ex (PyDateTime_DateTime * self , PyObject * args )
54245433{
5425- int proto = 0 ;
5426- if (!PyArg_ParseTuple (args , "| i:__reduce_ex__" , & proto ))
5434+ int proto ;
5435+ if (!PyArg_ParseTuple (args , "i:__reduce_ex__" , & proto ))
54275436 return NULL ;
54285437
54295438 return Py_BuildValue ("(ON)" , Py_TYPE (self ), datetime_getstate (self , proto ));
54305439}
54315440
5441+ static PyObject *
5442+ datetime_reduce (PyDateTime_DateTime * self , PyObject * arg )
5443+ {
5444+ return Py_BuildValue ("(ON)" , Py_TYPE (self ), datetime_getstate (self , 2 ));
5445+ }
5446+
54325447static PyMethodDef datetime_methods [] = {
54335448
54345449 /* Class methods: */
@@ -5503,9 +5518,12 @@ static PyMethodDef datetime_methods[] = {
55035518 {"astimezone" , (PyCFunction )datetime_astimezone , METH_VARARGS | METH_KEYWORDS ,
55045519 PyDoc_STR ("tz -> convert to local time in new timezone tz\n" )},
55055520
5506- {"__reduce_ex__" , (PyCFunction )datetime_reduce , METH_VARARGS ,
5521+ {"__reduce_ex__" , (PyCFunction )datetime_reduce_ex , METH_VARARGS ,
55075522 PyDoc_STR ("__reduce_ex__(proto) -> (cls, state)" )},
55085523
5524+ {"__reduce__" , (PyCFunction )datetime_reduce , METH_NOARGS ,
5525+ PyDoc_STR ("__reduce__() -> (cls, state)" )},
5526+
55095527 {NULL , NULL }
55105528};
55115529
0 commit comments