Paul Ganssle <p.gans...@gmail.com> added the comment: For future reference, this bug is triggered only when `.fromutc` is called on a subclass of `datetime` and the resulting date is the second ambiguous time (e.g. if there's a DST transition from 02:00 → 01:00, and the result of the `.fromutc` call is the *second* 01:30, you will trigger this issue).
Here's an MWE: ``` from backports.zoneinfo import ZoneInfo from datetime import datetime, timezone class SubDT(datetime): pass LON = ZoneInfo("Europe/London") d = SubDT(2020, 10, 25, 1, 30, tzinfo=timezone.utc) # Each pass through the loop inappropriately reduces the reference count on the # `1` object by 1. Since there are usually a large number of live references to # `1`, this won't have any immediate noticeable effect unless you do it a lot. for i in range(10000): d.astimezone(LON) ``` ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42697> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com