File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6761,6 +6761,9 @@ local_timezone_from_timestamp(time_t timestamp)
67616761 struct tm local_time_tm ;
67626762 PyObject * nameo = NULL ;
67636763 const char * zone = NULL ;
6764+ #ifndef HAVE_STRUCT_TM_TM_ZONE
6765+ char buf [100 ]; // for zone, which is used after the block below
6766+ #endif
67646767
67656768 if (_PyTime_localtime (timestamp , & local_time_tm ) != 0 )
67666769 return NULL ;
@@ -6771,9 +6774,9 @@ local_timezone_from_timestamp(time_t timestamp)
67716774 {
67726775 PyObject * local_time , * utc_time ;
67736776 struct tm utc_time_tm ;
6774- char buf [ 100 ];
6775- strftime ( buf , sizeof ( buf ), "%Z" , & local_time_tm ) ;
6776- zone = buf ;
6777+ if ( strftime ( buf , sizeof ( buf ), "%Z" , & local_time_tm ) != 0 ) {
6778+ zone = buf ;
6779+ }
67776780 local_time = new_datetime (local_time_tm .tm_year + 1900 ,
67786781 local_time_tm .tm_mon + 1 ,
67796782 local_time_tm .tm_mday ,
@@ -6783,8 +6786,10 @@ local_timezone_from_timestamp(time_t timestamp)
67836786 if (local_time == NULL ) {
67846787 return NULL ;
67856788 }
6786- if (_PyTime_gmtime (timestamp , & utc_time_tm ) != 0 )
6789+ if (_PyTime_gmtime (timestamp , & utc_time_tm ) != 0 ) {
6790+ Py_DECREF (local_time );
67876791 return NULL ;
6792+ }
67886793 utc_time = new_datetime (utc_time_tm .tm_year + 1900 ,
67896794 utc_time_tm .tm_mon + 1 ,
67906795 utc_time_tm .tm_mday ,
You can’t perform that action at this time.
0 commit comments