@@ -452,9 +452,9 @@ time_strftime(PyObject *self, PyObject *args)
452452 } else if (!gettmarg (tup , & buf ))
453453 return NULL ;
454454
455- /* Checks added to make sure strftime() does not crash Python by
456- indexing blindly into some array for a textual representation
457- by some bad index (fixes bug #897625).
455+ /* Checks added to make sure strftime() does not crash Python by
456+ indexing blindly into some array for a textual representation
457+ by some bad index (fixes bug #897625).
458458
459459 Also support values of zero from Python code for arguments in which
460460 that is out of range by forcing that value to the lowest value that
@@ -475,50 +475,50 @@ time_strftime(PyObject *self, PyObject *args)
475475 (1) gettmarg() handles bounds-checking.
476476 (2) Python's acceptable range is one greater than the range in C,
477477 thus need to check against automatic decrement by gettmarg().
478- */
478+ */
479479 if (buf .tm_mon == -1 )
480480 buf .tm_mon = 0 ;
481481 else if (buf .tm_mon < 0 || buf .tm_mon > 11 ) {
482- PyErr_SetString (PyExc_ValueError , "month out of range" );
483- return NULL ;
484- }
482+ PyErr_SetString (PyExc_ValueError , "month out of range" );
483+ return NULL ;
484+ }
485485 if (buf .tm_mday == 0 )
486486 buf .tm_mday = 1 ;
487487 else if (buf .tm_mday < 0 || buf .tm_mday > 31 ) {
488- PyErr_SetString (PyExc_ValueError , "day of month out of range" );
489- return NULL ;
490- }
491- if (buf .tm_hour < 0 || buf .tm_hour > 23 ) {
492- PyErr_SetString (PyExc_ValueError , "hour out of range" );
493- return NULL ;
494- }
495- if (buf .tm_min < 0 || buf .tm_min > 59 ) {
496- PyErr_SetString (PyExc_ValueError , "minute out of range" );
497- return NULL ;
498- }
499- if (buf .tm_sec < 0 || buf .tm_sec > 61 ) {
500- PyErr_SetString (PyExc_ValueError , "seconds out of range" );
501- return NULL ;
502- }
503- /* tm_wday does not need checking of its upper-bound since taking
504- ``% 7`` in gettmarg() automatically restricts the range. */
505- if (buf .tm_wday < 0 ) {
506- PyErr_SetString (PyExc_ValueError , "day of week out of range" );
507- return NULL ;
508- }
488+ PyErr_SetString (PyExc_ValueError , "day of month out of range" );
489+ return NULL ;
490+ }
491+ if (buf .tm_hour < 0 || buf .tm_hour > 23 ) {
492+ PyErr_SetString (PyExc_ValueError , "hour out of range" );
493+ return NULL ;
494+ }
495+ if (buf .tm_min < 0 || buf .tm_min > 59 ) {
496+ PyErr_SetString (PyExc_ValueError , "minute out of range" );
497+ return NULL ;
498+ }
499+ if (buf .tm_sec < 0 || buf .tm_sec > 61 ) {
500+ PyErr_SetString (PyExc_ValueError , "seconds out of range" );
501+ return NULL ;
502+ }
503+ /* tm_wday does not need checking of its upper-bound since taking
504+ ``% 7`` in gettmarg() automatically restricts the range. */
505+ if (buf .tm_wday < 0 ) {
506+ PyErr_SetString (PyExc_ValueError , "day of week out of range" );
507+ return NULL ;
508+ }
509509 if (buf .tm_yday == -1 )
510510 buf .tm_yday = 0 ;
511511 else if (buf .tm_yday < 0 || buf .tm_yday > 365 ) {
512- PyErr_SetString (PyExc_ValueError , "day of year out of range" );
513- return NULL ;
514- }
512+ PyErr_SetString (PyExc_ValueError , "day of year out of range" );
513+ return NULL ;
514+ }
515515 /* Normalize tm_isdst just in case someone foolishly implements %Z
516516 based on the assumption that tm_isdst falls within the range of
517517 [-1, 1] */
518- if (buf .tm_isdst < -1 )
519- buf .tm_isdst = -1 ;
518+ if (buf .tm_isdst < -1 )
519+ buf .tm_isdst = -1 ;
520520 else if (buf .tm_isdst > 1 )
521- buf .tm_isdst = 1 ;
521+ buf .tm_isdst = 1 ;
522522
523523#ifdef HAVE_WCSFTIME
524524 tmpfmt = PyBytes_FromStringAndSize (NULL ,
@@ -614,14 +614,15 @@ is not present, current time as returned by localtime() is used.");
614614static PyObject *
615615time_strptime (PyObject * self , PyObject * args )
616616{
617- PyObject * strptime_module = PyImport_ImportModuleNoBlock ("_strptime" );
618- PyObject * strptime_result ;
619-
620- if (!strptime_module )
621- return NULL ;
622- strptime_result = PyObject_CallMethod (strptime_module , "_strptime_time" , "O" , args );
623- Py_DECREF (strptime_module );
624- return strptime_result ;
617+ PyObject * strptime_module = PyImport_ImportModuleNoBlock ("_strptime" );
618+ PyObject * strptime_result ;
619+
620+ if (!strptime_module )
621+ return NULL ;
622+ strptime_result = PyObject_CallMethod (strptime_module ,
623+ "_strptime_time" , "O" , args );
624+ Py_DECREF (strptime_module );
625+ return strptime_result ;
625626}
626627
627628PyDoc_STRVAR (strptime_doc ,
0 commit comments