[Python-Dev] PEP 431 Updates

Lennart Regebro regebro at gmail.com
Mon Jan 28 12:53:26 CET 2013


On Mon, Jan 28, 2013 at 11:26 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Will non-ambiguous shorthands such as "Warsaw" and "GMT" be accepted?

pytz accepts GMT, so that will work. Otherwise no.

> NonExistentTimeError can also be raised for is_dst=True and
> is_dst=False, no? Or am I misunderstanding the semantics?

No, it will only be raised when is_dst=None. The flag is there to say
what timezone the resulting time should be if it is ambiguous or
missing.

It is true that the times that don't exist will also not exist even if
you set the flag. 2012-03-25 02:30 is a time that don't exist in
Europe/Warsaw, flag or not. But it will not raise an error if you set
the flag to False or True, for reasons of backwards compatibility as
well as ease of handling. People don't expect that certain times don't
exist, and will generally not check for those exceptions. Therefore,
the normal behavior is to not raise an error, but happily keep dealing
with the time as if it does exist. Only of you explicitly set it to
"None" will you get an error.

//Lennart


More information about the Python-Dev mailing list