[Datetime-SIG] PEP-495 - Strict Invalid Time Checking

ISAAC J SCHWABACHER ischwabacher at wisc.edu
Tue Aug 25 23:07:00 CEST 2015


[Alexander Belopolsky]
> Whatever your requirements are, the difference between "strict checking" and PEP 495 code will be the same as between

> dt = get_naive_time()
> try:
>     dt = dt.astimezone()
> except AmbiguousTimeError:
>     # do something
> except MissingTimeError:
>     # do something else
> else:
>     # use dt

It's obvious to me what this code means.

> and

> dt = get_naive_time()
> dt0 = dt.replace(fold=0).astimezone()
> dt1 = dt.replace(fold=1).astimezone()
> if dt1 > dt0:
>     # do something
> elif dt1 < dt0:
>     # do something else
> else:
>     # use dt0 which is the same as dt1

The only thing that's obvious to me about this code is that it's hacking around something.

ijs


More information about the Datetime-SIG mailing list