@@ -104,7 +104,7 @@ def _normalize(self, dt, dst_rule=None): # type: (_D, Optional[str]) -> _D
104104 # We set the fold attribute for later
105105 if dst_rule == POST_TRANSITION :
106106 fold = 1
107- else :
107+ elif transition . previous is not None :
108108 transition = transition .previous
109109
110110 if transition :
@@ -149,7 +149,7 @@ def _convert(self, dt): # type: (_D) -> _D
149149 transition = dt .tzinfo ._lookup_transition (stamp )
150150 offset = transition .ttype .offset
151151
152- if stamp < transition .local :
152+ if stamp < transition .local and transition . previous is not None :
153153 if (
154154 transition .previous .is_ambiguous (stamp )
155155 and getattr (dt , "fold" , 1 ) == 0
@@ -161,7 +161,7 @@ def _convert(self, dt): # type: (_D) -> _D
161161 stamp -= offset
162162
163163 transition = self ._lookup_transition (stamp , is_utc = True )
164- if stamp < transition .at :
164+ if stamp < transition .at and transition . previous is not None :
165165 transition = transition .previous
166166
167167 offset = transition .ttype .offset
@@ -260,7 +260,7 @@ def _get_transition(self, dt): # type: (_datetime) -> Transition
260260
261261 transition = self ._lookup_transition (stamp )
262262
263- if stamp < transition .local :
263+ if stamp < transition .local and transition . previous is not None :
264264 fold = getattr (dt , "fold" , 1 )
265265 if transition .is_ambiguous (stamp ):
266266 if fold == 0 :
@@ -276,7 +276,7 @@ def fromutc(self, dt): # type: (_D) -> _D
276276 stamp = timestamp (dt )
277277
278278 transition = self ._lookup_transition (stamp , is_utc = True )
279- if stamp < transition .at :
279+ if stamp < transition .at and transition . previous is not None :
280280 transition = transition .previous
281281
282282 stamp += transition .ttype .offset
0 commit comments