[Datetime-SIG] pytz vs. PEP 495 Was: PEP-431/495

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Aug 24 21:14:40 CEST 2015


On Mon, Aug 24, 2015 at 3:05 PM, Ethan Furman <ethan at stoneleaf.us> wrote:

> I would be much happier about this if:
>
>  >>> datetime(2004, 4, 4, 2, first=None,
> tzinfo=Eastern2).astimezone().isoformat()
>  Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File ".../pytz/tzinfo.py", line 327, in localize
>      raise NonExistentTimeError(dt)
>  NonExistentTimeError: 2004-04-04 02:00:00
>
> Giving the programmer an easier option to use if they want an exception.
>

Which of the steps you want to raise an exception:

>>> dt = datetime(2004, 4, 4, 2, first=None, tzinfo=Eastern2)
>>> ldt = dt.astimezone()

or

>>> ldt.isoformat()

and why?

The stack trace that you presented comes for "localize", but no such method
is proposed in PEP 495.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150824/9c505c62/attachment-0001.html>


More information about the Datetime-SIG mailing list