File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 66
77- Fixed the ` weeks ` property for negative ` Period ` instances.
88- Fixed ` start_of() ` methods not setting microseconds to 0.
9+ - Fixed errors on some systems when retrieving timezone from clock files.
910
1011
1112## [ 2.0.1] - 2018-05-10
Original file line number Diff line number Diff line change 1414from typing import Union
1515
1616from .timezone import Timezone , TimezoneFile
17+ from .zoneinfo .exceptions import InvalidTimezone
1718
1819
1920_mock_local_timezone = None
@@ -200,16 +201,16 @@ def _get_unix_timezone(_root='/'): # type: (str) -> Timezone
200201 line = line [match .end ():]
201202 etctz = line [:end_re .search (line ).start ()]
202203
203- parts = etctz .replace (' ' , '_' ).split ('/' )[- 2 :]
204+ parts = list (reversed (etctz .replace (' ' , '_' ).split ('/' )))
205+ tzpath = []
204206 while parts :
205- tzpath = '/' .join (parts )
207+ tzpath .insert (0 , parts .pop (0 ))
208+
206209 try :
207- return Timezone (tzpath )
208- except ( ValueError , IOError , OSError ) :
210+ return Timezone ('/' . join ( tzpath ) )
211+ except InvalidTimezone :
209212 pass
210213
211- parts .pop (0 )
212-
213214 # systemd distributions use symlinks that include the zone name,
214215 # see manpage of localtime(5) and timedatectl(1)
215216 tzpath = os .path .join (_root , 'etc/localtime' )
You can’t perform that action at this time.
0 commit comments