@@ -2798,20 +2798,22 @@ date_new(PyTypeObject *type, PyObject *args, PyObject *kw)
27982798 int day ;
27992799
28002800 /* Check for invocation from pickle with __getstate__ state */
2801- if (PyTuple_GET_SIZE (args ) == 1 &&
2802- PyBytes_Check (state = PyTuple_GET_ITEM (args , 0 )) &&
2803- PyBytes_GET_SIZE (state ) == _PyDateTime_DATE_DATASIZE &&
2804- MONTH_IS_SANE (PyBytes_AS_STRING (state )[2 ]))
2805- {
2806- PyDateTime_Date * me ;
2807-
2808- me = (PyDateTime_Date * ) (type -> tp_alloc (type , 0 ));
2809- if (me != NULL ) {
2810- char * pdata = PyBytes_AS_STRING (state );
2811- memcpy (me -> data , pdata , _PyDateTime_DATE_DATASIZE );
2812- me -> hashcode = -1 ;
2801+ if (PyTuple_GET_SIZE (args ) == 1 ) {
2802+ state = PyTuple_GET_ITEM (args , 0 );
2803+ if (PyBytes_Check (state ) &&
2804+ PyBytes_GET_SIZE (state ) == _PyDateTime_DATE_DATASIZE &&
2805+ MONTH_IS_SANE (PyBytes_AS_STRING (state )[2 ]))
2806+ {
2807+ PyDateTime_Date * me ;
2808+
2809+ me = (PyDateTime_Date * ) (type -> tp_alloc (type , 0 ));
2810+ if (me != NULL ) {
2811+ char * pdata = PyBytes_AS_STRING (state );
2812+ memcpy (me -> data , pdata , _PyDateTime_DATE_DATASIZE );
2813+ me -> hashcode = -1 ;
2814+ }
2815+ return (PyObject * )me ;
28132816 }
2814- return (PyObject * )me ;
28152817 }
28162818
28172819 if (PyArg_ParseTupleAndKeywords (args , kw , "iii" , date_kws ,
@@ -3913,43 +3915,46 @@ time_new(PyTypeObject *type, PyObject *args, PyObject *kw)
39133915
39143916 /* Check for invocation from pickle with __getstate__ state */
39153917 if (PyTuple_GET_SIZE (args ) >= 1 &&
3916- PyTuple_GET_SIZE (args ) <= 2 &&
3917- PyBytes_Check (state = PyTuple_GET_ITEM (args , 0 )) &&
3918- PyBytes_GET_SIZE (state ) == _PyDateTime_TIME_DATASIZE &&
3919- (0x7F & ((unsigned char ) (PyBytes_AS_STRING (state )[0 ]))) < 24 )
3918+ PyTuple_GET_SIZE (args ) <= 2 )
39203919 {
3921- PyDateTime_Time * me ;
3922- char aware ;
3923-
3924- if (PyTuple_GET_SIZE (args ) == 2 ) {
3925- tzinfo = PyTuple_GET_ITEM (args , 1 );
3926- if (check_tzinfo_subclass (tzinfo ) < 0 ) {
3927- PyErr_SetString (PyExc_TypeError , "bad "
3928- "tzinfo state arg" );
3929- return NULL ;
3930- }
3931- }
3932- aware = (char )(tzinfo != Py_None );
3933- me = (PyDateTime_Time * ) (type -> tp_alloc (type , aware ));
3934- if (me != NULL ) {
3935- char * pdata = PyBytes_AS_STRING (state );
3936-
3937- memcpy (me -> data , pdata , _PyDateTime_TIME_DATASIZE );
3938- me -> hashcode = -1 ;
3939- me -> hastzinfo = aware ;
3940- if (aware ) {
3941- Py_INCREF (tzinfo );
3942- me -> tzinfo = tzinfo ;
3943- }
3944- if (pdata [0 ] & (1 << 7 )) {
3945- me -> data [0 ] -= 128 ;
3946- me -> fold = 1 ;
3920+ state = PyTuple_GET_ITEM (args , 0 );
3921+ if (PyBytes_Check (state ) &&
3922+ PyBytes_GET_SIZE (state ) == _PyDateTime_TIME_DATASIZE &&
3923+ (0x7F & ((unsigned char ) (PyBytes_AS_STRING (state )[0 ]))) < 24 )
3924+ {
3925+ PyDateTime_Time * me ;
3926+ char aware ;
3927+
3928+ if (PyTuple_GET_SIZE (args ) == 2 ) {
3929+ tzinfo = PyTuple_GET_ITEM (args , 1 );
3930+ if (check_tzinfo_subclass (tzinfo ) < 0 ) {
3931+ PyErr_SetString (PyExc_TypeError , "bad "
3932+ "tzinfo state arg" );
3933+ return NULL ;
3934+ }
39473935 }
3948- else {
3949- me -> fold = 0 ;
3936+ aware = (char )(tzinfo != Py_None );
3937+ me = (PyDateTime_Time * ) (type -> tp_alloc (type , aware ));
3938+ if (me != NULL ) {
3939+ char * pdata = PyBytes_AS_STRING (state );
3940+
3941+ memcpy (me -> data , pdata , _PyDateTime_TIME_DATASIZE );
3942+ me -> hashcode = -1 ;
3943+ me -> hastzinfo = aware ;
3944+ if (aware ) {
3945+ Py_INCREF (tzinfo );
3946+ me -> tzinfo = tzinfo ;
3947+ }
3948+ if (pdata [0 ] & (1 << 7 )) {
3949+ me -> data [0 ] -= 128 ;
3950+ me -> fold = 1 ;
3951+ }
3952+ else {
3953+ me -> fold = 0 ;
3954+ }
39503955 }
3956+ return (PyObject * )me ;
39513957 }
3952- return (PyObject * )me ;
39533958 }
39543959
39553960 if (PyArg_ParseTupleAndKeywords (args , kw , "|iiiiO$i" , time_kws ,
@@ -4552,43 +4557,46 @@ datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw)
45524557
45534558 /* Check for invocation from pickle with __getstate__ state */
45544559 if (PyTuple_GET_SIZE (args ) >= 1 &&
4555- PyTuple_GET_SIZE (args ) <= 2 &&
4556- PyBytes_Check (state = PyTuple_GET_ITEM (args , 0 )) &&
4557- PyBytes_GET_SIZE (state ) == _PyDateTime_DATETIME_DATASIZE &&
4558- MONTH_IS_SANE (PyBytes_AS_STRING (state )[2 ] & 0x7F ))
4560+ PyTuple_GET_SIZE (args ) <= 2 )
45594561 {
4560- PyDateTime_DateTime * me ;
4561- char aware ;
4562-
4563- if (PyTuple_GET_SIZE (args ) == 2 ) {
4564- tzinfo = PyTuple_GET_ITEM (args , 1 );
4565- if (check_tzinfo_subclass (tzinfo ) < 0 ) {
4566- PyErr_SetString (PyExc_TypeError , "bad "
4567- "tzinfo state arg" );
4568- return NULL ;
4569- }
4570- }
4571- aware = (char )(tzinfo != Py_None );
4572- me = (PyDateTime_DateTime * ) (type -> tp_alloc (type , aware ));
4573- if (me != NULL ) {
4574- char * pdata = PyBytes_AS_STRING (state );
4575-
4576- memcpy (me -> data , pdata , _PyDateTime_DATETIME_DATASIZE );
4577- me -> hashcode = -1 ;
4578- me -> hastzinfo = aware ;
4579- if (aware ) {
4580- Py_INCREF (tzinfo );
4581- me -> tzinfo = tzinfo ;
4582- }
4583- if (pdata [2 ] & (1 << 7 )) {
4584- me -> data [2 ] -= 128 ;
4585- me -> fold = 1 ;
4562+ state = PyTuple_GET_ITEM (args , 0 );
4563+ if (PyBytes_Check (state ) &&
4564+ PyBytes_GET_SIZE (state ) == _PyDateTime_DATETIME_DATASIZE &&
4565+ MONTH_IS_SANE (PyBytes_AS_STRING (state )[2 ] & 0x7F ))
4566+ {
4567+ PyDateTime_DateTime * me ;
4568+ char aware ;
4569+
4570+ if (PyTuple_GET_SIZE (args ) == 2 ) {
4571+ tzinfo = PyTuple_GET_ITEM (args , 1 );
4572+ if (check_tzinfo_subclass (tzinfo ) < 0 ) {
4573+ PyErr_SetString (PyExc_TypeError , "bad "
4574+ "tzinfo state arg" );
4575+ return NULL ;
4576+ }
45864577 }
4587- else {
4588- me -> fold = 0 ;
4578+ aware = (char )(tzinfo != Py_None );
4579+ me = (PyDateTime_DateTime * ) (type -> tp_alloc (type , aware ));
4580+ if (me != NULL ) {
4581+ char * pdata = PyBytes_AS_STRING (state );
4582+
4583+ memcpy (me -> data , pdata , _PyDateTime_DATETIME_DATASIZE );
4584+ me -> hashcode = -1 ;
4585+ me -> hastzinfo = aware ;
4586+ if (aware ) {
4587+ Py_INCREF (tzinfo );
4588+ me -> tzinfo = tzinfo ;
4589+ }
4590+ if (pdata [2 ] & (1 << 7 )) {
4591+ me -> data [2 ] -= 128 ;
4592+ me -> fold = 1 ;
4593+ }
4594+ else {
4595+ me -> fold = 0 ;
4596+ }
45894597 }
4598+ return (PyObject * )me ;
45904599 }
4591- return (PyObject * )me ;
45924600 }
45934601
45944602 if (PyArg_ParseTupleAndKeywords (args , kw , "iii|iiiiO$i" , datetime_kws ,
0 commit comments